Skip to content

Fetch errors from import.meta.glob paths in preview #13503

Closed
@stephenlrandall

Description

@stephenlrandall

Describe the bug

A follow-up to #13362. When using import.meta.glob and then fetching the resulting files, any non-inlined assets in the built application have /_app/immutable/... paths. When deployed (https://stephenlrandall.github.io/kit-preview-issue/), this works fine. But during preview, "Not found" errors are produced.

Reproduction

https://github.com/stephenlrandall/kit-preview-issue

Logs

requesting resource: /_app/immutable/assets/sample.lmZegr8j.json
SyntaxError: Unexpected token 'N', "Not found" is not valid JSON
    at JSON.parse (<anonymous>)
    at Proxy.<anonymous> (file:///Users/randasl1/Desktop/kit-cors-issue/.svelte-kit/output/server/index.js:1324:25)
    at async load (file:///Users/randasl1/Desktop/kit-cors-issue/.svelte-kit/output/server/entries/pages/_page.js:8:16)
    at async load_data (file:///Users/randasl1/Desktop/kit-cors-issue/.svelte-kit/output/server/index.js:1231:18)
    at async file:///Users/randasl1/Desktop/kit-cors-issue/.svelte-kit/output/server/index.js:2794:18

System Info

System:
    OS: macOS 15.3.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 47.19 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.8.0 - /usr/local/bin/node
    npm: 10.1.0 - /usr/local/bin/npm
    pnpm: 10.4.1 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 133.0.6943.127
    Edge: 133.0.3065.82
    Safari: 18.3
  npmPackages:
    @sveltejs/adapter-static: ^3.0.8 => 3.0.8 
    @sveltejs/kit: ^2.17.3 => 2.17.3 
    @sveltejs/vite-plugin-svelte: ^4.0.4 => 4.0.4 
    svelte: ^5.20.4 => 5.20.4 
    vite: ^5.4.14 => 5.4.14

Severity

serious, but I can work around it

Additional Information

The workaround is to just not use preview, which isn't the end of the world but isn't really a workaround either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions