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

🐛 BUG: Sub-path not working correctly when mimicking nextjs output #2434

Closed
wbern opened this issue Jan 20, 2022 · 2 comments
Closed

🐛 BUG: Sub-path not working correctly when mimicking nextjs output #2434

wbern opened this issue Jan 20, 2022 · 2 comments
Assignees

Comments

@wbern
Copy link

wbern commented Jan 20, 2022

What version of astro are you using?

0.22.16

What package manager are you using?

pnpm

What operating system are you using?

wsl2

Describe the Bug

I am mimicking the way our next apps output static content, in astro, because that works better with our current workflows in CI.

I have

dist/
    sub-path.html
    sub-path/[assets]

In astro, when I try to do the same behavior, with dist output set to sub-path, but moving the index.html to a level above, the dynamic imports don't work properly. (mv dist/sub-path/index.html dist/sub-path.html)

I realize this is probably because astro seems to rely on the trailing slash being present in the url (eg. http://localhost:8081/sub-path/, and being one level higher prevents that from working. In our case, we don't have trailing slashes.

It would be nice to be able to supply some value to Vite or otherwise, to set the path to what should be correct.

buildOptions.site seems to have no effect on this.

  buildOptions: {
    site: 'http://localhost:8081/sub-path',           // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
    // sitemap: false, // Generate sitemap (set to "false" to disable)
  },

Sorry for making a repro without stackblitz, I made it before opening the issue...

How to repro:

  1. clone the repo
  2. install the deps
  3. run npm run docker-start
  4. open localhost:8081/sub-path.html, it will have errors for the dynamic imports.

Link to Minimal Reproducible Example

https://github.com/wbern/repro-astro-subpath

@jonathantneal
Copy link
Contributor

Thanks for making an issue for this. I’m sharing some information here from the related PR.

The related PR has been held up, because we know we shouldn’t (and probably can’t) block requests outside of the subpath. However, it looks like there’s a problem in the current solution if it doesn’t and those requests get passed along.

@tony-sull
Copy link
Contributor

This may have been fixed in PR2494 when we switched to using Vite's built-in server

@wbern would you mind upgrading your project to the latest version of Astro to see if you're still hitting this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants