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

Links to static assets do not work #1492

Closed
lovasoa opened this issue May 19, 2021 · 6 comments
Closed

Links to static assets do not work #1492

lovasoa opened this issue May 19, 2021 · 6 comments

Comments

@lovasoa
Copy link
Contributor

lovasoa commented May 19, 2021

Describe the bug

When creating a link to a static asset, clicking the link triggers a 404 instead of opening the asset.

Logs

The issue doesn't log anything.

To Reproduce

In the default sveltekit app:

  • Create a file in static/hello.txt with the contents hello world
  • In src/index.svelte, add the following link: <a href="/hello.txt">xxx</a>

run npm run dev, then, from your browser, click the link

Expected behavior

The text file is loaded

Actual behavior
A 404 error

Information about your SvelteKit Installation:

Diagnostics

  System:
    OS: macOS 11.2.2
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 292.30 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.1.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.11.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 90.0.4430.212
    Firefox: 88.0.1
    Safari: 14.0.3
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.107 
    svelte: ^3.34.0 => 3.38.2 

Severity
Caused a broken link in production for me in
https://sanipasse.fr/french-health-pass

@mvolfik
Copy link
Contributor

mvolfik commented May 19, 2021

You probably need to set rel=external on the link: https://kit.svelte.dev/docs#anchor-options-rel-external

@lovasoa
Copy link
Contributor Author

lovasoa commented May 19, 2021

rel=external is for links to external sites. In this case, I am linking to a resource on my own site.

SvelteKit knows which static assets it has, so there is no reason that we can't make it work with a normal link, is there ?

@tobi-or-not-tobi
Copy link

I assume this is fixed by #1487

@benmccann
Copy link
Member

This sounds like a duplicate of #1295

@mvolfik
Copy link
Contributor

mvolfik commented May 19, 2021

Yes, it is a duplicate. But let me just point out that this isn't solved by the patch (not)tobi mentions - that solves the case if you have app base /foo/bar and navigate to /

@lovasoa
Copy link
Contributor Author

lovasoa commented May 19, 2021

Oh, yes, I did not find that original issue. Sorry.

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

No branches or pull requests

4 participants