Skip to content

Prerendering a page that uses navigateTo results in an error #1402

@tobiasdiez

Description

@tobiasdiez

Environment

  • Operating System: Windows_NT
  • Node Version: v19.9.0
  • Nuxt Version: 3.6.2
  • Nitro Version: 2.5.2

Reproduction

Do you have a starter template for reproductions?

Describe the bug

If you use navigateTo on a (nuxt) page that is prerendered, the prerendering fails as the status code is 302 and not 200:

Prerendering 4 initial routes with crawler                        nitro 20:02:29
  ├─ ....
  ├─ /download (208ms) (Error: [302] )                               nitro 20:02:31
                                                                     nitro 20:02:31  
Errors prerendering:
  ├─ /download (302)

Additional context

This error comes from the check
https://github.com/unjs/nitro/blob/6bc50b2f9416dc9af6ba327440deea2ec8e35a33/src/prerender.ts#L171-L176.

If one adds res.status !== 302 it works well. I can open a PR with this fix, but I'm not sure if there are any negative consequences or if there is a better way to handle prerenders of redirects.

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions