Skip to content

basePath option is not working #131

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

Closed
vitorbal opened this issue Mar 12, 2021 · 10 comments · Fixed by #374
Closed

basePath option is not working #131

vitorbal opened this issue Mar 12, 2021 · 10 comments · Fixed by #374
Assignees
Labels
priority: medium type: bug code to address defects in shipped code

Comments

@vitorbal
Copy link

Describe the bug
If you set up a very simple nextjs app with the basePath option configured, the deployed website will 404 a bunch of static asset paths. Here's an example for a basePath of /cats-of-zapier:

To Reproduce
Steps to reproduce the behavior:

  1. Create a new next.js app
  2. Add basePath: '/foo' to next.config.js
  3. Deploy the app to netlify
  4. Navigate to the deployment and notice how all of the prefixed assets 404

Expected behavior
For the app to be served correctly, with no 404s.

Versions

  • Next.js: 10.0.7
  • plugin (if installed at fixed version): latest, I guess? Enabled from the Netlify UI
@jlengstorf jlengstorf added the type: bug code to address defects in shipped code label Mar 12, 2021
@jlengstorf
Copy link

hey, @vitorbal! do you have a reproduction available for us to review? and/or the build logs for the failing deploy? that helps us track things down much more quickly

thank you!

@jdeal
Copy link

jdeal commented Mar 14, 2021

@vitorbal does this forum post help?

@vitorbal
Copy link
Author

@jlengstorf thanks!

as you can see / is serving what should be served by /foo, and all the static assets 404. If you try navigating to /foo, it 404s, so something is wrong with the runtime there.

@vitorbal
Copy link
Author

@jdeal thanks for sharing that forum post! It sort of helps, but in their case, they are deploying an app via next export. I'm interested in deploying a next app in serverless mode, so this plugin can be leveraged to support SSRd pages, etc.

@jlengstorf
Copy link

hey, @vitorbal — I think I know the issue here. with basePath, the assumption is that the site will be served from https://example.com/foo/, so you'd redirect to your app like so:

/foo/*  https://604defe6294def94d336b2a7--hungry-chandrasekhar-0c40c1.netlify.app/:splat  200

I set up an example of this:

source code:

let me know if this makes sense. thanks!

@lindsaylevine
Copy link

hey @vitorbal! did jason's comment solve your issue? let us know so we can close the issue or continue to try to help! :D

@vitorbal
Copy link
Author

Howdy folks! Apologies for the lul.

@jlengstorf I checked out your app and even though it solves the problem, I would expect a standalone next.js app to work without those redirects.

If you run your next app locally, the basePath config works without a problem, so I would expect it to work once deployed too. Similarly, if you deploy your next app to a node server instead of a serverless platform like Netlify, the basePath config also works without any redirects.

If it helps, I deployed the reproduction case to Vercel and it also works as expected there: https://next-basepath.vercel.app/foo

@lunelson
Copy link

lunelson commented Mar 22, 2021

@vitorbal @jlengstorf I've just run in to this too. I don't think redirecting from root to a subpath is the right solution. When I run next build and then next start on my site locally, it serves the built site under the subpath (in my case /blog), and that's the way it should work here too. Also: please verify the solution with the trailingSlash: true setting as well

@lindsaylevine
Copy link

@vitorbal @lunelson hello! i'll explore how we might solve this within the plugin. will let you know!!!

@vitorbal
Copy link
Author

@lindsaylevine @jlengstorf sounds good, thank you both for being so responsive!

@lindsaylevine lindsaylevine self-assigned this May 26, 2021
serhalp pushed a commit that referenced this issue Apr 5, 2024
* ci: run tests on canary and skip none

* DIsable one so script works

* Use manifest v2

* Remove old filter step

* Fix versions

* Exclude invalid tests

* Exclude more

* Use junit

* Set cwd for test report

* Try massive concurrency

* Fix concurrency

* Use different test reporter

* Adjust condiitons

* Typo

* Fix junit path

* Disable more

* fix: shim process in edge runtime

* Switch reporter action

* ci: fix artifact path

* Disable very slow tests

* Add test runner

* Use md formatter

* Add deno install step to task

* Fix tool path

* Disable test

* Skip bad tests

* Omit non-deploy test

* Skip tests that are failing because of whitespace in headers

* Continute on error in local tests

* Skip a non-deploy test

* Skip xff test

* Skip tests that try to patch files

* Checkout runtime in report step

* DIsable more flaky tests

* Fix script name

* Log cast totals

* Format better
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants