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

paths.base production build routing issue #8091

Closed
inzanez opened this issue Dec 12, 2022 · 7 comments
Closed

paths.base production build routing issue #8091

inzanez opened this issue Dec 12, 2022 · 7 comments
Labels
awaiting submitter paths.base bugs relating to `config.kit.paths.base`

Comments

@inzanez
Copy link

inzanez commented Dec 12, 2022

Describe the problem

Hi all

I serve a Svelte application through a reverse proxy under a sub-path like http://my-site.com/sub/path. When forwarding the requests, the reverse proxy rewrites the path so that /sub/path gets removed, resulting in requets to the Svelte deployment as if it were hosted at the root.
To make this work, I set paths.base to /sub/path. Using the node adapter, it prepended that paths.base to every static asset URL so that it was correctly fetched.

After upgrading to the most recent version of @sveltejs/kit and @adapter/node things do not seem to work anymore. When setting the paths.base variable, it seems that the resulting node build expects me to hit the server with the routes ${paths.base}/actual-route. Which is not really how it used to work,...

Describe the proposed solution

Fix routing based on paths.base...

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@inzanez inzanez changed the title paths.base production build routing issue paths.base production build routing issue Dec 12, 2022
@dummdidumm
Copy link
Member

  • from what version did you upgrade?
  • please provide a reproducible

@inzanez
Copy link
Author

inzanez commented Dec 12, 2022

I did upgrade from:

"@sveltejs/adapter-node": "^1.0.0-next.46",
"@sveltejs/kit": "^1.0.0-next.166",
"svelte": "^3.46.4",
...

to

"@sveltejs/adapter-node": "^1.0.0-next.104",
"@sveltejs/kit": "^1.0.0-next.577",
"svelte": "^3.46.4",

I do not see how I could deliver a reproducible as it all depends on the proxy being in place and rewriting URLs,...?

@dummdidumm
Copy link
Member

dummdidumm commented Dec 12, 2022

Wow that's ... a big jump 😅 Could you check what happens if you're pinning the version to 1.0.0-next.578 (the last one that uses Vite 3; so you need to pin that to 3 as well)? Want to make sure it's not a result of that.

Re "how": You could provide a GitHub repository with all the necessary things wired up. For the proxy, a thorough explanation how to set it up (maybe there's a way to use a simpler proxy that can also be included in the GitHub repo and setup correctly).

@inzanez
Copy link
Author

inzanez commented Dec 12, 2022

@dummdidumm Yes, it is quite a jump :-) Well, I will try and put something together, that might take some time though. I have just tried a fresh project and played around with the static adapter,...and I think I have seen some weird routing behavior as well (at least from what I am used to).

I will be back with a repo and more detailed information,...

@inzanez
Copy link
Author

inzanez commented Dec 12, 2022

@dummdidumm
https://github.com/inzanez/svelte-routing

There are two branches, old-version and new-version. You might register the difference between the two.
Have the final application using only relative paths so that it will fetch the right assets and work wherever it is hosted (path-wise,...so it might be 10 levels deep in a folder structure on an nginx server but it would still run).

All in all, it seems that the behavior changed from the older version to the newer. With the newer, I would have to turn off the path-rewriting in the proxy.

@dummdidumm dummdidumm added the paths.base bugs relating to `config.kit.paths.base` label Dec 12, 2022
@dummdidumm
Copy link
Member

maybe you are seing the changed behavior due to this PR #4448 which fixed the longstanding issue #3726 . If so, then that's expected and you need to adjust your path-rewriting.

@inzanez
Copy link
Author

inzanez commented Dec 13, 2022

@dummdidumm Yes, that seems to be the case :-) Absolutely agree with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter paths.base bugs relating to `config.kit.paths.base`
Projects
None yet
Development

No branches or pull requests

2 participants