Linking to pdf files inside `public` folder doesn't work on routing.
I have a repo that builds on top of solid-start here: https://github.com/nikitavoloboev/nikitavoloboev
I have a pdf file in public called cv.pdf: https://github.com/nikitavoloboev/nikitavoloboev/blob/main/public/cv.pdf
If I for example do this:
https://github.com/nikitavoloboev/nikitavoloboev/blob/a0ab2a594e77e0cbcc450de56099a15aa4691c06/src/components/Nav.tsx#L37
<a class="nav-link" href="./cv.pdf">
CV
</a>
Inside the app if I go to this page, it will 404:
https://www.loom.com/share/900b34ae19904c59aed372d2a7457103
Not sure what I am doing wrong. I need to refresh the page for the PDF to actually show.
I can confirm this and also the same thing happens for api routes.
Seems like this happens because links are handled by https://github.com/solidjs/solid-app-router while files inside the public folder and api routes are not known by solid-app-router.
API routes also do not currently support parametric and wildcard routes like regular routes since that part is also handled by solid-app-router. I was about to make a PR for that but I'm now thinking there needs to be a bigger change to consolidate how routing works.
EDIT: Thought a bit more about it. This would require the client knowing all the files in the public directory / all the api routes, which I'm not sure is a good idea. Or not being able to handle 404s client-side without verifying with the server.
EDIT 2: This could probably be handled by some attribute on the <a> indicating that routing should be handled by the server not sure if there is already support for that.
EDIT 3: Just tried it you can add target _self and it will work correctly.
<a class="nav-link" href="./cv.pdf" target="_self">
CV
</a>
@ghalle you are correct. It doesn't make sense for the client router to handle these cases. I believe setting rel="external" or setting target on the link is the easiest way.
We need to get the docs written for this.
Now that we changed how the router works and it doesn't hijack every anchor I think this is no longer a problem. You can just do what the OP did and it works.