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

request route with param and folder in static with same name returns error on dev mode #5791

Open
CordlessWool opened this issue Aug 2, 2022 · 4 comments
Labels
blocked by upstream bug Something isn't working vite
Milestone

Comments

@CordlessWool
Copy link

Describe the bug

In the project, I have a route and a folder in static with the same name (images). Loading images/someimage.jpg working well, but accessing just images?somepaream produce an error.

Failed to load url /images?load=%2Fimages%2Fteaser.jpg (resolved id: /images?load=%2Fimages%2Fteaser.jpg). This file is in /public and will be copied as-is during build without going through the plugin transforms, and therefore should not be imported from source code. It can only be referenced via HTML tags.

Seems relating to #5672 but in a more special way.
After build there is no problem, only in dev mode I get this error.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-yefxpo?file=src/routes/index.svelte

Logs

9:05:21 PM [vite] Internal server error: Failed to load url /images?load=%2Fimages%2Fteaser.jpg (resolved id: /images?load=%2Fimages%2Fteaser.jpg). This file is in /public and will be copied as-is during build without going through the plugin transforms, and therefore should not be imported from source code. It can only be referenced via HTML tags.
      at loadAndTransform (file:///home/wolle/Workspace/vally/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:39798:19)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) (x2)

System Info

System:
    OS: Linux 5.18 Fedora Linux 36 (Workstation Edition)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 8.51 GB / 15.35 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chrome: 103.0.5060.134
    Firefox: 102.0

Severity

serious, but I can work around it

Additional Information

No response

@benmccann benmccann added bug Something isn't working vite labels Aug 8, 2022
@benmccann
Copy link
Member

It would be helpful to know if this happens with a plain Vite project or only with SvelteKit: https://github.com/sveltejs/kit#bug-reporting

@CordlessWool
Copy link
Author

What I currently know is that it didn't happen with a version of sveltekit before 39x. I do not have the exact version in mind.

@CordlessWool
Copy link
Author

CordlessWool commented Aug 29, 2022

I tried to rebuild it with vite vanilla, but I never did a project with vite beside svelte kit so I am not sure if I test it correctly, but I didn't get an error.

I created a project with npm create vite-extra@latest -- --template ssr-svelte

Afterwards I added a route in server.js for GET requests on /images and I created a folder images in public. It toke the server route and didn't throw an error. So for me it looks like everything is ok in vite.

@Rich-Harris Rich-Harris added this to the whenever milestone Sep 20, 2022
@dummdidumm
Copy link
Member

I'm pretty sure this is a Vite issue - our code correctly determines that this is not a static asset since it's a directory, then calls the next middleware which happens to be Vite's which then throws the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by upstream bug Something isn't working vite
Projects
None yet
Development

No branches or pull requests

4 participants