Links to static assets do not work
See original GitHub issueDescribe 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 contentshello 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
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Express-js can't GET my static files, why? - Stack Overflow
This solved my issue. In my code, path to CSS was working fine even with the __dirname concatenation (using path.join), while fetching js...
Read more >Clicking anchor links to valid static files results in a 404 and ...
If you have an link to any static asset, when you click the link, the SPA renders the $error ... Links to static...
Read more >How to manage static files (e.g. images, JavaScript, CSS)
Store your static files in a folder called static in your app. For example my_app/static/my_app/example.
Read more >Static Asset Handling - Vite
Explicit URL Imports #. Assets that are not included in the internal list or in assetsInclude , can be explicitly imported as a...
Read more >Static Files - Hugo
By default, the static/ directory in the site project is used for all static files (e.g. stylesheets, JavaScript, images). The static files are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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/
Oh, yes, I did not find that original issue. Sorry.