Skip to content

Middleware redirect does not work if the page file doesn't exist #7752

@raulfdm

Description

@raulfdm

What version of astro are you using?

2.9.0

Are you using an SSR adapter? If so, which one?

Not relevant

What package manager are you using?

pnpm

What operating system are you using?

Stackblitz

What browser are you using?

Not relevant

Describe the Bug

I have a project where I always want to redirect the user from the entry point (/) to a locale page (/en).

If the src/pages/index.astro doesn't exist, this redirect won't happen if we do this via middleware.

Is this correct? I searched in the documentation but I haven't found anything.

CleanShot.2023-07-21.at.19.12.41.mp4

What's the expected result?

No need to have an empty index to I can redirect.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-rfraau?file=src%2Fmiddleware.ts

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions