Skip to content

Regression bug with configuredRedirects: local relative redirects are being interpreted as external urls #13607

@lfilho

Description

@lfilho

Astro Info

Astro                    v5.6.1
Node                     v23.7.0
System                   macOS (arm64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             @astrojs/react
                         @astrojs/sitemap
                         @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Hi! Just upagraded to 5.6 after a while, and saw that this line here introduced a regression bug, described below.

Basically, I have a complicated but necessary logic that configures a redirect during compile time, in looks like this:

    redirects: {
        '/cv/pdf': pdfRelativePath,
    },

where pdfRelativePath is the result of a function doing that complex compile time calculation I mentioned. The path needs to be relative so it can work both for localhost and production, so it starts with ../. But as you can see on the line I mentioned above, if it doesn't see a value starting with /, it thinks it's an external URL, and then it fails with [UnsupportedExternalRedirect] An external redirect must start with http or https, and must be a valid URL. since it doesn't start with http nor https.

So could we change the conditional to also support relative paths again?

What's the expected result?

Local relative paths should work as before 😊

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-mstiazbh?file=astro.config.mjs

Participation

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

Metadata

Metadata

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)feat: redirectsRelated to the redirects feature (scope)regression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions