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
Jasmin
Jasmin8mo ago
@ghost_soul0 Where are you hosting your website? You need to configure your proxy to always direct to / as we're working with an SPA
ghost_soul0
ghost_soul0OP8mo ago
i am hosting it on vercel
Jasmin
Jasmin8mo ago
with the default vite preset?
ghost_soul0
ghost_soul0OP8mo ago
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
Jasmin
Jasmin8mo ago
hm the default vite preset should configure it properly already ohh nevermind here:
Jasmin
Jasmin8mo ago
create a vercel.json file in the project root and insert that
ghost_soul0
ghost_soul0OP8mo ago
yup 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
Jasmin
Jasmin8mo ago
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.
ghost_soul0
ghost_soul0OP8mo ago
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 .
Jasmin
Jasmin8mo ago
you're welcome! Yeah, watch some youtube videos regarding SPA's. Might clear up some open questions :)
Want results from more Discord servers?
Add your server