question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Links to static assets do not work

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mvolfikcommented, 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 /

0reactions
lovasoacommented, May 19, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found