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

Start from version 1.0.0-next.337 to current 1.0.0-next.343 , use [...path].svelte will overwrite assets import urls #5066

Closed
TrungRueta opened this issue May 24, 2022 · 2 comments

Comments

@TrungRueta
Copy link

TrungRueta commented May 24, 2022

Describe the bug

start from version 1.0.0-next.337 to current 1.0.0-next.343. when define a route file to catch error 404 (file named [...path].svelte) , it will catch asset urls imported in source too. This issue not happend until ver 1.0.0-next.336 .

Change log 337

i guess that the change in v*.337 regards to
Only run viteServeStaticMiddleware after server has attempted response (https://github.com/sveltejs/kit/pull/4974) will be cause. But dont know how to help fix.

Reproduction

  • create new fresh svelte-kit project use npm init svelte <folder project name>
  • add image into /src/lib/assets/a.jpg
  • from file /src/routes/index.svelte import image to <script> block, then create <img> tag in template.
  • in /src/routes create new file name [...path].svelte, define some html like a 404 catcher page.
  • run npm run dev. see image url in chrome devtool will redirect to [...path].svelte page .
  • rename file [...path].svelte to [path].svelte. run dev serer again, see img show correctly.
  • try add file [...path].svelte again, then run build npm run buildand thennpm run preview`, the built version work ok so issue only happend with dev mode.

Logs

No response

System Info

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 81.88 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.11.1 - ~/.nvm/versions/node/v16.11.1/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.3.0 - ~/.nvm/versions/node/v16.11.1/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Safari: 15.3
  npmPackages:
    svelte: ^3.44.0 => 3.48.0

Severity

blocking an upgrade

@Conduitry Conduitry transferred this issue from sveltejs/svelte May 24, 2022
Rich-Harris added a commit that referenced this issue May 25, 2022
@TrungRueta
Copy link
Author

workaround to have both assets url and 404 page is change [...path].svelte to [path].svelte. because order of routes, [path].svelte has lowest priority and still match any url not catched by higher priority routes. And assets url not matched with this format because assets urls has file .ext .

Rich-Harris added a commit that referenced this issue Jul 5, 2022
Rich-Harris added a commit that referenced this issue Jul 6, 2022
Rich-Harris added a commit that referenced this issue Jul 8, 2022
* failing test for #5066

* allow vite to serve files where appropriate

* print helpful 403 in dev

* Update packages/kit/src/vite/dev/index.js

* try and figure out why windows is failing

* try this

* store protocol and verbose instead of vite_config

* neaten up

* account for server.fs.strict

* Update packages/kit/test/apps/basics/test/test.js

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>

* Create nice-boxes-exercise.md

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
@Rich-Harris
Copy link
Member

closed via #5070

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

2 participants