Skip to content
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

Passing args in URL with experimental.basePath causes the page to constantly being reloaded. #13132

Closed
robertovg opened this issue May 20, 2020 · 7 comments · Fixed by #13560
Closed
Assignees
Labels
good first issue Easy to fix issues, good for newcomers
Milestone

Comments

@robertovg
Copy link

Bug report

Describe the bug

We are using next: "^9.4.1" in a project with experimental.basePath and when working with the project on development and we have params on URL the page constantly reloads making impossible to work on dev mode.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

I generated a simple repo & code-sandbox to show the problem.

  • Contains a basepath set to myPath
  • Only contains a simple index page with a link to add params to the URL,

When you load the visit the project with params: Live Sandbox and click on the link, o directly go to the URL with params on the URL

The page loads correctly, but after a second it starts to reload from time to time.

If no params in the URL or experimental.basePath set, it works like as expected.

Expected behavior

I would like to work with experimental.basePath without unexpected page reloads.

Additional context

Obviously this is an experimental feature based on this PR but we will need sooner than later in our projects.

Thanks in advance 🙏

@ijjk
Copy link
Member

ijjk commented May 20, 2020

Hi, it looks like you are setting both assetPrefix and basePath to the same path here. You only need to set basePath in this case since /_next requests will automatically be prefixed with the basePath

@DrUNE
Copy link

DrUNE commented May 20, 2020

Hi, I think this is related problem #11992 (comment) here basePath used instead assetPrefix. Problem surface when basePath and assetPrefix used at the same time in the project for generating SSG for example for static site which need basePath for routing prefixes and the same time all static assets should be hosted on another domain or CDN

@robertovg
Copy link
Author

Hi, it looks like you are setting both assetPrefix and basePath to the same path here. You only need to set basePath in this case since /_next requests will automatically be prefixed with the basePath

Yeah, but in our real case, we are routing this next.js application through Traefik through the same base_path, and we need both the app and the assets to be served inside the same base_path.
That's why we need to change both.

@designbyadrian
Copy link

I'm having the same issue without setting assetPrefix. I'm trying to narrow down the problem.

@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers help wanted labels May 25, 2020
@TyMick
Copy link
Contributor

TyMick commented May 27, 2020

Okay this is weird: after cloning @robertovg's repo, I experience those same reloading issues when I yarn dev, but when I yarn build && yarn start, going to http://localhost:3000/myPath?reloadsWithAnyParam=true no longer causes reloading.

I then thought that it must be a server-side rendering issue, but then I tried adding a getServerSideProps() to src/pages/index.js...

export async function getServerSideProps(context) {
  return {
    props: {},
  };
}

...and after yarn build confirmed for me that the index page would be server-side rendered at runtime, I still experienced no reloading issues after yarn start and visiting http://localhost:3000/myPath?reloadsWithAnyParam=true. So I am only experiencing the reloading bug in dev mode, regardless of how the page is rendered. 🤔

@Timer Timer added this to the 9.4.3 milestone May 27, 2020
@Timer Timer modified the milestones: 9.4.3, 9.4.4 May 28, 2020
@TyMick
Copy link
Contributor

TyMick commented May 28, 2020

Found which reload we're dealing with:

Continuing to investigate around there...

@Timer Timer removed the help wanted label Jun 3, 2020
@kodiakhq kodiakhq bot closed this as completed in #13560 Jun 5, 2020
kodiakhq bot pushed a commit that referenced this issue Jun 5, 2020
So I can't *entirely* explain why, but I believe this fixes #13132. 🙈 I basically ended up looking around at other `_next` URLs (are those asset URLs?) around the project and seeing that they tended to use `delBasePath()` to remove the base path from the current page's path whenever it was used.

When testing locally with the [repo submitted with the issue](https://github.com/robertovg/next-base-path-example), I no longer experience the constant page-reloading in dev mode when adding a query string to the URL.
@Timer Timer added the kind: bug label Jun 8, 2020
@Timer Timer assigned Timer and ijjk Jun 8, 2020
@Timer Timer reopened this Jun 8, 2020
@Timer Timer modified the milestones: 9.4.5, 9.x.x Jun 8, 2020
@Timer Timer closed this as completed Jun 8, 2020
@Timer Timer modified the milestones: 9.x.x, june 2020 Jun 8, 2020
rokinsky pushed a commit to rokinsky/next.js that referenced this issue Jul 11, 2020
So I can't *entirely* explain why, but I believe this fixes vercel#13132. 🙈 I basically ended up looking around at other `_next` URLs (are those asset URLs?) around the project and seeing that they tended to use `delBasePath()` to remove the base path from the current page's path whenever it was used.

When testing locally with the [repo submitted with the issue](https://github.com/robertovg/next-base-path-example), I no longer experience the constant page-reloading in dev mode when adding a query string to the URL.
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants