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

Linking to pdf files inside public folder doesn't work on routing. #120

Closed
Tracked by #157
nikitavoloboev opened this issue May 23, 2022 · 3 comments
Closed
Tracked by #157
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@nikitavoloboev
Copy link

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.

@ghalle
Copy link
Collaborator

ghalle commented May 23, 2022

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>

@ryansolid
Copy link
Member

ryansolid commented May 23, 2022

@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.

@nksaraf nksaraf added the documentation Improvements or additions to documentation label Jun 28, 2022
@nksaraf nksaraf self-assigned this Jun 28, 2022
@ryansolid
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants