kit
kit copied to clipboard
Redirect in action does not respect status code
Describe the bug
If a form action redirects, the status code passed into redirect(status, location)
is always replaced with 303
.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-cq96ae?file=src/routes/+page.server.js
Click the button and look at the console logs. You'll see a 303 redirect even though we passed in "302".
Logs
Status code: 200
Status code: 303
Status code: 200
System Info
System:
OS: macOS 13.0.1
CPU: (10) arm64 Apple M1 Pro
Memory: 62.42 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.9.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 9.1.3 - /opt/homebrew/bin/npm
Browsers:
Chrome: 108.0.5359.124
Safari: 16.1
npmPackages:
@sveltejs/adapter-auto: ^1.0.0 => 1.0.0
@sveltejs/kit: ^1.0.0 => 1.0.1
svelte: ^3.54.0 => 3.55.0
vite: ^4.0.0 => 4.0.1
Severity
serious, but I can work around it
Additional Information
I'm guessing this isn't a big deal for most of the client rendered apps out there. But if there are any server rendered apps that rely on non-303 redirects from a form action, e.g. a Permanent redirect, this will be important.