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

Netlify Adapter 404 assets when kit.paths.base is defined #4442

Closed
asendia opened this issue Mar 24, 2022 · 0 comments · Fixed by #4448
Closed

Netlify Adapter 404 assets when kit.paths.base is defined #4442

asendia opened this issue Mar 24, 2022 · 0 comments · Fixed by #4448
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. paths.base bugs relating to `config.kit.paths.base`
Milestone

Comments

@asendia
Copy link
Contributor

asendia commented Mar 24, 2022

Describe the bug

As titled, when kit.paths.base is defined, the asset requests (js, css, etc) get 404 from /[kit.paths.base]/_app. The actual assets are still accessible from /_app.

In local env, npm run preview can correctly load assets from /[kit.paths.base]/_app.

Reproduction

I have modified the svelte.config.js in this stackblitz link. Run npm run build and you will get the 404 error.

Logs

No response

System Info

System:
    OS: macOS 12.3
    CPU: (8) arm64 Apple M1
    Memory: 277.94 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 99.0.4844.83
    Firefox: 92.0.1
    Safari: 15.4
  npmPackages:
    @sveltejs/adapter-netlify: next => 1.0.0-next.51 
    @sveltejs/kit: next => 1.0.0-next.301 
    @sveltejs/svelte-virtual-list: ^3.0.1 => 3.0.1 
    svelte: ^3.44.0 => 3.46.4

Severity

serious, but I can work around it

Additional Information

I execute this workaround script in postbuild, assuming kit.paths.base = 'test':

# Move assets to base dir
mv build/_app build/test/_app
# Update default netlify headers
sed -i '' "s/_app/test\/_app/g" build/_headers
hmnd added a commit to hmnd/svelte-kit that referenced this issue Mar 24, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- add base path to dest for builder.writeStatic, builder.writeClient, builder.writePrerendered
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Mar 24, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Mar 25, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Mar 25, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
@Rich-Harris Rich-Harris added the bug Something isn't working label Apr 4, 2022
hmnd added a commit to hmnd/svelte-kit that referenced this issue Apr 9, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Apr 27, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Apr 27, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
@Rich-Harris Rich-Harris added the paths.base bugs relating to `config.kit.paths.base` label May 16, 2022
@Rich-Harris Rich-Harris added this to the 1.0 milestone May 16, 2022
@benmccann benmccann added the p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. label Jul 19, 2022
hmnd added a commit to hmnd/svelte-kit that referenced this issue Jul 22, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Jul 22, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Jul 22, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Sep 2, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Sep 2, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Sep 2, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Sep 16, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.prefix and builder.getAppPrefixDirectory()
- adapter-cloudflare*: use manifest.prefix instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Sep 29, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.appPath and builder.getAppPath()
- adapter-cloudflare*: use manifest.appPath instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
hmnd added a commit to hmnd/svelte-kit that referenced this issue Sep 30, 2022
fixes sveltejs#4442, fixes sveltejs#2843

- add manifest.appPath and builder.getAppPath()
- adapter-cloudflare*: use manifest.appPath instead of manifest.appDir
- adapter-netlify: use prefixed appDir for cache headers
- adapter-vercel: use prefixed appDir for routes.json
- adapter-cloudflare, adapter-cloudflare-workers, adapter-netlify: write static assets to "$dest/$base"
dummdidumm pushed a commit that referenced this issue Oct 12, 2022
fixes #4442, fixes #2843, fixes #3726

Write static files to a folder that takes into account the base path value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. paths.base bugs relating to `config.kit.paths.base`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants