sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.53k stars 1.91k forks source link

404 requesting asset in prerendered page #1070

Closed navneetsharmaui closed 3 years ago

navneetsharmaui commented 3 years ago

Describe the bug When using adapter-static the application is not building properly when the route component contains the async load function to load the data from JSON file and when a page contains the nested layouts/routes.

  1. When using the async load function to load the data from the JSON file
  2. When the page contains the nested layouts/routes.
  3. While building the nested layout it tries to refer to the favicon.ico in its folder and tries to create the favicon.ico folder.

Logs

  1. This occurs when using SSR options is false in the configuration. adapter-static-three-nf-nssr

  2. This occurs when using SSR options is false in the configuration and force option is true in prender in configuration. adapter-static-four-f-nssr

  3. This occurs when using SSR options is true in the configuration. adapter-static-two-no-f

  4. This occurs when using SSR options is true in the configuration and force option is true in prender in configuration. adapter-static-one

sveltekit-build-folder-structure

Svelte Config svelte-config

To Reproduce

  1. Create the application with the latest version of sveltekit and add adapter-static as a dev dependency.
  2. Create the route with nested layouts, create a settings route with profile and notification as nested layouts.
  3. Try to create an application with the following folder structure. svelte-kit-full-folder-structure

Repo you can refer to for the code. https://github.com/navneetsharmaui/sveltekit-starter

benmccann commented 3 years ago

Better prerendering error messages were added in https://github.com/sveltejs/kit/pull/1062. Can you upgrade to the latest version of SvelteKit and see if you get a more informative error message?

navneetsharmaui commented 3 years ago

@benmccann The sveltekit version is 1.0.0-next.83 And the is the screenshot of the build error now updated-svektekit-1 0 0-next 83

For the nested layouts, the child route layout is still trying to link the favicon.ico into its immediate parent directory rather than to the favicon.ico which is present at the root build folder. sveltekit-build-folder

Dependencies info sveltekit-dependencies-info

benmccann commented 3 years ago

Getting a 404 on an .ico file seems likely to be a usage issue and fairly unlikely to be a bug in SvelteKit.

I'd recommend you take a look at this FAQ: https://github.com/sveltejs/kit/blob/master/documentation/faq/45-assets.md

If that doesn't help, try asking on Discord

Rich-Harris commented 3 years ago

Looks like you have a relative favicon.ico link instead of an absolute one, like this: https://github.com/sveltejs/kit/blob/32b3fcde3c206347d0ca58ea2f8ecec649f5b7f5/packages/create-svelte/templates/default/src/app.html#L5