-
Notifications
You must be signed in to change notification settings - Fork 27.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid adding basePath when it's not needed #14535
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When using the `basePath` setting, on pages with params it will fire a router change. This will pass the url pathname in the `as` param using the `getUrl()` function. This means the `as` path will be sent through already including the `basePath`, leading to `/basePath/basePath/path` which will cause the router to throw an error.
anthonyshort
requested review from
ijjk,
lfades,
Timer and
timneutkens
as code owners
June 24, 2020 18:27
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall increase
|
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 13.2s | 13s | -181ms |
nodeModulesSize | 67.2 MB | 67.2 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.179 | 2.128 | -0.05 |
/ avg req/sec | 1147.29 | 1174.99 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.255 | 1.297 | |
/error-in-render avg req/sec | 1991.68 | 1927.2 | -64.48 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.js gzip | 6.49 kB | 6.49 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..14a7.js gzip | 10.7 kB | 10.7 kB | |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57.1 kB | 57.1 kB |
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.57 kB | 5.57 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..dule.js gzip | 7.07 kB | 7.07 kB | |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Build Manifests
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 267 B | 267 B | ✓ |
_buildManife..dule.js gzip | 272 B | 272 B | ✓ |
Overall change | 539 B | 539 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 954 B | 956 B | |
link.html gzip | 962 B | 961 B | -1 B |
withRouter.html gzip | 947 B | 948 B | |
Overall change | 2.86 kB | 2.87 kB |
Diffs
Diff for 19b7e98f51cc..ae.module.js
@@ -669,7 +669,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
var basePath = false || "";
function addBasePath(path) {
- return "".concat(basePath).concat(path);
+ return path.startsWith(basePath)
+ ? path
+ : "".concat(basePath).concat(path);
}
function delBasePath(path) {
Diff for 19b7e98f51cc..2341fc613.js
@@ -799,7 +799,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
var basePath = false || "";
function addBasePath(path) {
- return "".concat(basePath).concat(path);
+ return path.startsWith(basePath)
+ ? path
+ : "".concat(basePath).concat(path);
}
function delBasePath(path) {
Diff for index.html
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.af0f7c24035cfb520019.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -117,13 +117,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.84ae27d08f82341fc613.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.2fda4ad3d0d18300dcc2.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.af0f7c24035cfb520019.module.js"
async=""
crossorigin="anonymous"
type="module"
Diff for link.html
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.af0f7c24035cfb520019.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -122,13 +122,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.84ae27d08f82341fc613.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.2fda4ad3d0d18300dcc2.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.af0f7c24035cfb520019.module.js"
async=""
crossorigin="anonymous"
type="module"
Diff for withRouter.html
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.af0f7c24035cfb520019.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -117,13 +117,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.84ae27d08f82341fc613.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.2fda4ad3d0d18300dcc2.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.af0f7c24035cfb520019.module.js"
async=""
crossorigin="anonymous"
type="module"
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 14.1s | 14s | -37ms |
nodeModulesSize | 67.2 MB | 67.2 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.js gzip | 6.49 kB | 6.49 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..14a7.js gzip | 10.7 kB | N/A | N/A |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
19b7e98f51cc..566a.js gzip | N/A | 10.7 kB | N/A |
Overall change | 57.1 kB | 57.1 kB |
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.57 kB | 5.57 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..dule.js gzip | 7.07 kB | N/A | N/A |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
19b7e98f51cc..dule.js gzip | N/A | 7.07 kB | N/A |
Overall change | 52.5 kB | 52.5 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Build Manifests
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 267 B | 267 B | ✓ |
_buildManife..dule.js gzip | 272 B | 272 B | ✓ |
Overall change | 539 B | 539 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
_error.js | 875 kB | 875 kB | ✓ |
404.html | 4.17 kB | 4.17 kB | ✓ |
hooks.html | 3.79 kB | 3.79 kB | ✓ |
index.js | 876 kB | 876 kB | ✓ |
link.js | 916 kB | 916 kB | |
routerDirect.js | 908 kB | 908 kB | |
withRouter.js | 908 kB | 908 kB | |
Overall change | 4.49 MB | 4.49 MB |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ijjk
approved these changes
Jun 25, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I went ahead and added a test case to ensure we don't regress on this and also tweaked the fix a bit to ensure the behavior of delBasePath
isn't changed and the other tests are still passing
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 10.3s | 10.4s | |
nodeModulesSize | 67.2 MB | 67.2 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.688 | 1.696 | |
/ avg req/sec | 1481.26 | 1474.06 | -7.2 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 0.986 | 1.004 | |
/error-in-render avg req/sec | 2534.78 | 2490.57 | -44.21 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.js gzip | 6.49 kB | 6.5 kB | |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..14a7.js gzip | 10.7 kB | 10.7 kB | |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57.1 kB | 57.1 kB |
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.57 kB | 5.59 kB | |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..dule.js gzip | 7.07 kB | 7.07 kB | |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Build Manifests
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 267 B | 267 B | ✓ |
_buildManife..dule.js gzip | 272 B | 272 B | ✓ |
Overall change | 539 B | 539 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 954 B | 956 B | |
link.html gzip | 962 B | 960 B | -2 B |
withRouter.html gzip | 947 B | 947 B | ✓ |
Overall change | 2.86 kB | 2.86 kB | ✓ |
Diffs
Diff for 19b7e98f51cc..ae.module.js
@@ -912,7 +912,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
pathname: addBasePath(_pathname),
query: _query
}),
- _as
+ addBasePath(_as)
);
}
Diff for 19b7e98f51cc..2341fc613.js
@@ -1051,7 +1051,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
pathname: addBasePath(_pathname),
query: _query
}),
- _as
+ addBasePath(_as)
);
}
Diff for main-HASH.js
@@ -273,6 +273,8 @@
var _utils = __webpack_require__("g/15");
+ var _router2 = __webpack_require__("elyg");
+
var _headManager = _interopRequireDefault(__webpack_require__("DqTX"));
var _pageLoader = _interopRequireDefault(__webpack_require__("zmvN"));
@@ -313,7 +315,7 @@
serverRuntimeConfig: {},
publicRuntimeConfig: runtimeConfig || {}
});
- var asPath = (0, _utils.getURL)();
+ var asPath = (0, _router2.delBasePath)((0, _utils.getURL)());
var pageLoader = new _pageLoader["default"](buildId, prefix, page);
var register = function register(_ref) {
Diff for main-HASH.module.js
@@ -191,6 +191,8 @@
var _utils = __webpack_require__("g/15");
+ var _router2 = __webpack_require__("elyg");
+
var _headManager = _interopRequireDefault(__webpack_require__("DqTX"));
var _pageLoader = _interopRequireDefault(__webpack_require__("zmvN"));
@@ -233,7 +235,7 @@
serverRuntimeConfig: {},
publicRuntimeConfig: runtimeConfig || {}
});
- var asPath = (0, _utils.getURL)();
+ var asPath = (0, _router2.delBasePath)((0, _utils.getURL)());
var pageLoader = new _pageLoader.default(buildId, prefix, page);
var register = _ref => {
Diff for index.html
@@ -6,7 +6,7 @@
<meta name="next-head-count" content="2" />
<link
rel="preload"
- href="/_next/static/runtime/main-44231f8dcc4c3aad570c.module.js"
+ href="/_next/static/runtime/main-19eb7ee5a14e78d5c3f0.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6562b366da40ce1e34e8.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -81,13 +81,13 @@
src="/_next/static/runtime/polyfills-b9d354b83d10fbe21b38.js"
></script>
<script
- src="/_next/static/runtime/main-9bb13ca99cde7b5d3ad1.js"
+ src="/_next/static/runtime/main-f59fa8078161f9914786.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/runtime/main-44231f8dcc4c3aad570c.module.js"
+ src="/_next/static/runtime/main-19eb7ee5a14e78d5c3f0.module.js"
async=""
crossorigin="anonymous"
type="module"
@@ -117,13 +117,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.84ae27d08f82341fc613.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.f1f4e02fdab29f2d0c89.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6562b366da40ce1e34e8.module.js"
async=""
crossorigin="anonymous"
type="module"
Diff for link.html
@@ -6,7 +6,7 @@
<meta name="next-head-count" content="2" />
<link
rel="preload"
- href="/_next/static/runtime/main-44231f8dcc4c3aad570c.module.js"
+ href="/_next/static/runtime/main-19eb7ee5a14e78d5c3f0.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6562b366da40ce1e34e8.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -86,13 +86,13 @@
src="/_next/static/runtime/polyfills-b9d354b83d10fbe21b38.js"
></script>
<script
- src="/_next/static/runtime/main-9bb13ca99cde7b5d3ad1.js"
+ src="/_next/static/runtime/main-f59fa8078161f9914786.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/runtime/main-44231f8dcc4c3aad570c.module.js"
+ src="/_next/static/runtime/main-19eb7ee5a14e78d5c3f0.module.js"
async=""
crossorigin="anonymous"
type="module"
@@ -122,13 +122,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.84ae27d08f82341fc613.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.f1f4e02fdab29f2d0c89.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6562b366da40ce1e34e8.module.js"
async=""
crossorigin="anonymous"
type="module"
Diff for withRouter.html
@@ -6,7 +6,7 @@
<meta name="next-head-count" content="2" />
<link
rel="preload"
- href="/_next/static/runtime/main-44231f8dcc4c3aad570c.module.js"
+ href="/_next/static/runtime/main-19eb7ee5a14e78d5c3f0.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ href="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6562b366da40ce1e34e8.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -81,13 +81,13 @@
src="/_next/static/runtime/polyfills-b9d354b83d10fbe21b38.js"
></script>
<script
- src="/_next/static/runtime/main-9bb13ca99cde7b5d3ad1.js"
+ src="/_next/static/runtime/main-f59fa8078161f9914786.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/runtime/main-44231f8dcc4c3aad570c.module.js"
+ src="/_next/static/runtime/main-19eb7ee5a14e78d5c3f0.module.js"
async=""
crossorigin="anonymous"
type="module"
@@ -117,13 +117,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.84ae27d08f82341fc613.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.f1f4e02fdab29f2d0c89.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.49eb0f00d05cbc3d1aae.module.js"
+ src="/_next/static/chunks/19b7e98f51cc0d86c45d01159bbbfb942bfe49b8.6562b366da40ce1e34e8.module.js"
async=""
crossorigin="anonymous"
type="module"
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 11s | 11.1s | |
nodeModulesSize | 67.2 MB | 67.2 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.js gzip | 6.49 kB | 6.5 kB | |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..14a7.js gzip | 10.7 kB | N/A | N/A |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
19b7e98f51cc..834a.js gzip | N/A | 10.7 kB | N/A |
Overall change | 57.1 kB | 57.1 kB |
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.57 kB | 5.59 kB | |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
19b7e98f51cc..dule.js gzip | 7.07 kB | N/A | N/A |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
19b7e98f51cc..dule.js gzip | N/A | 7.07 kB | N/A |
Overall change | 52.5 kB | 52.5 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Build Manifests
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 267 B | 267 B | ✓ |
_buildManife..dule.js gzip | 272 B | 272 B | ✓ |
Overall change | 539 B | 539 B | ✓ |
Serverless bundles
vercel/next.js canary | anthonyshort/next.js patch-1 | Change | |
---|---|---|---|
_error.js | 875 kB | 875 kB | ✓ |
404.html | 4.17 kB | 4.17 kB | ✓ |
hooks.html | 3.79 kB | 3.79 kB | ✓ |
index.js | 876 kB | 876 kB | ✓ |
link.js | 916 kB | 916 kB | ✓ |
routerDirect.js | 908 kB | 908 kB | ✓ |
withRouter.js | 908 kB | 908 kB | ✓ |
Overall change | 4.49 MB | 4.49 MB | ✓ |
Great! Thanks for wrapping this up for me 👍🏻 |
rokinsky
pushed a commit
to rokinsky/next.js
that referenced
this pull request
Jul 11, 2020
* Avoid adding basePath when it's not needed When using the `basePath` setting, on pages with params it will fire a router change. This will pass the url pathname in the `as` param using the `getUrl()` function. This means the `as` path will be sent through already including the `basePath`, leading to `/basePath/basePath/path` which will cause the router to throw an error. * lint * Add test case and ensure removal * Make sure to re-add before changeState Co-authored-by: JJ Kasper <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug description
When using the
basePath
on pages with params it will fire a router change. This will pass the url pathname in theas
param using thegetUrl()
function. When the app is mounted on a sub-path (which is the whole point of thebasePath
) the url will fromwindow.location.href
which will already include the base path.What this means is that the
as
path will be sent through to the router already including thebasePath
, leading to/basePath/basePath/path
which will cause the router to throw an error about mis-matchedas
andhref
params.Reproduction
Here's a reproduction that uses nginx to route
/sub/path
to the Next app. ThebasePath
is also set to/sub/path
. It's not trying to do anything special other than rendering and grabbing the param using the router hook.yarn install
yarn docker:up