Why do I keep on getting GET http://localhost:8080/index.html?next=/gameserver-rs/_app/immutable/chunks/D47ybobq.js 404
in axum, like why is it not prefixed with /gameserver-rs/, I don't get where the whole redirect thing is coming from
I get those issues when the page first loads up, because I am using svelte I had to make it so it prefixed the paths correctly, but now it re-directs to something that does not have the prefix
To put it plainly, its supposed to go to
http://localhost:8080/gameserver-rs/index.html
not
http://localhost:8080/index.html
Full code (in main.rs) if needed but my pastebin snippet has everything relevant:
Since you're using nested routes, and since the problem is that your code is generating a URI that is missing a piece of that nesting, it's likely that your code is extracting Uri
when it should be extracting OriginalUri
. The Axum documentation for Router::nest
warns about this in passing:
How the URI changes
Note that nested routes will not see the original request URI but instead have the matched prefix stripped. This is necessary for services like static file serving to work. Use OriginalUri
if you need the original request URI.
Since you didn't tell us what request you are sending to produce the suspect redirect, it's a little tricky to trace through your code and tell you precisely where you need to swap out one for the other, but my immediate suspicion falls on your authenticate_route
middleware function, since that's the only spot I can see generating redirects at all.
6 Likes
Thanks! That was it, I was looking everywhere except the only place that actually handled redirects.. which was authenticate_route.. upon fixing that, all the assets load properly.