direct Access to pages resulting in 404 error
i'm encountering a situation where accessing pages directly via their URLs leads to a 404 error, but navigating to them after loading the main website doesn't produce any errors. could someone help me troubleshoot this issue? it seems to be related to routing. thank you!
11 Replies
@ghost_soul0 Where are you hosting your website? You need to configure your proxy to always direct to
/
as we're working with an SPAi am hosting it on vercel
with the default vite preset?
idk
sorry
i just installed vercel client
could you please tell me how to configure the proxy ? i am not familiar with configuring proxies, this is my first project i am working on
yes yes
hm the default vite preset should configure it properly already
ohh nevermind
here:
Vite on Vercel
Learn how to use Vercel's features with Vite.
create a
vercel.json
file in the project root and insert thatyup now i am able to access any page with url also without first going to the main route
thank you so much
what was the reason i wasnt able to access pages with url ?
can you please explain it to me
you're running an SPA, which only servers one single page (the root page,
index.html
). And solid-router resolves the url and renders the matching component, but this all happens on the same page. So even if a user navigates to /otherpage, you need to serve the index.html
and solid-router than matches the /otherpage
and renders the matching component.thank you so much for explaining , i almost understood why this issue but little bit confused this was new to know , will learn more as i work more with these. thank you for helping me resolve this issue .
you're welcome! Yeah, watch some youtube videos regarding SPA's. Might clear up some open questions :)