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

paths.base regression between next.227 and next.228 #4927

Closed
pelletier197 opened this issue May 14, 2022 · 3 comments · Fixed by #4928
Closed

paths.base regression between next.227 and next.228 #4927

pelletier197 opened this issue May 14, 2022 · 3 comments · Fixed by #4928
Labels
bug Something isn't working
Milestone

Comments

@pelletier197
Copy link

pelletier197 commented May 14, 2022

Describe the bug

I have a website with a customized paths.base set to /api/docs. My ìndex.svelte is a pretty basic file that has a redirect in it, redirecting to the first page of my website (which in my case is /introduction/welcome):

<script context="module" lang="ts">
  import type { LoadInput, LoadOutput } from '@sveltejs/kit'

  export function load({ stuff }: LoadInput): LoadOutput {
    return {
      status: 302,
      redirect: '/introduction/welcome',
    }
  }
</script>

In version next.227, my website could be successfully built and all the html files were built. Starting from next.228, the build step no longer takes the redirect from index.svelte and doesn't render the rest of the website. I am almost certain it is linked to this commit, but I am not entirely sure.

Details

  • I use svelte-static adapter
  • I have a customized paths.base configuration
  • index.svelte redirects to another page
    • in my case, the rest of my website is based on dynamic paths. Since the redirect is not handled, my website html files are not generated at all.

Reproduction

I've made a minimal reproduction example:

https://github.com/pelletier197/sveltekit-bug-reproduction

In case it may be useful, my full project is public and available here.

Logs

No response

System Info

System:
    OS: Linux 5.17 Pop!_OS 22.04 LTS
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 19.35 GB / 31.00 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.4 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 96.1.33.106
    Chrome: 101.0.4951.41
    Firefox: 100.0
  npmPackages:
    @sveltejs/adapter-static: 1.0.0-next.30 => 1.0.0-next.30 
    @sveltejs/kit: 1.0.0-next.330 => 1.0.0-next.330 
    svelte: ^3.48.0 => 3.48.0

Severity

blocking an upgrade

Additional Information

No response

@Rich-Harris Rich-Harris added the bug Something isn't working label May 14, 2022
@Rich-Harris Rich-Harris added this to the 1.0 milestone May 14, 2022
@ssssota
Copy link

ssssota commented May 14, 2022

I'm encountering the same problem.
In my case, it is a normal SSG page with no redirects, etc.

@Rich-Harris
Copy link
Member

This is fixed by #4928. Note that there's a bug in the repro though, which may or may not be present in your app (in which case it presumably only surfaced with the more recent versions of Kit) — the redirect doesn't take paths.base into account.

It should be changed like so:

<script context="module" lang="ts">
+	import { base } from '$app/paths';
	import type { LoadInput, LoadOutput } from '@sveltejs/kit';
	export function load({ stuff }: LoadInput): LoadOutput {
		return {
			status: 302,
-			redirect: '/introduction/welcome'
+			redirect: `${base}/introduction/welcome`
		};
	}
</script>

@pelletier197
Copy link
Author

pelletier197 commented May 14, 2022

Oh you're right about the repro, my bad. It was not present in my app. Thanks for the quick fix!

Rich-Harris added a commit that referenced this issue May 15, 2022
* only skip files that were already written when prerendering - fixes #4927

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

Successfully merging a pull request may close this issue.

3 participants