Skip to content

Returning location from POST does not set 3xx status code #5976

@sandstromdev

Description

@sandstromdev

Describe the bug

When returning a location path from a +page.server.ts sveltekit set status as 200, and does not perform a redirect.

The problem is located in packages/kit/src/runtime/server/page/index.js at 81:38

return redirect_response(status, result.location);

where status is not changed from 200 (at 57:5)

let status = 200;

I'd be willing to submit a PR to fix this issue.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-t26lrz?file=src/routes/+page.svelte

The page contains two buttons:

  • Submit form with throw redirect()
  • Submit form with location

Logs

No response

System Info

System:
    OS: macOS 12.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 69.66 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
    npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
  Browsers:
    Firefox Developer Edition: 104.0
    Safari: 15.6
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.64 
    @sveltejs/adapter-node: 1.0.0-next.86 => 1.0.0-next.86 
    @sveltejs/kit: 1.0.0-next.415 => 1.0.0-next.415 
    svelte: ^3.49.0 => 3.49.0 
    vite: ^3.0.8 => 3.0.8

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions