next/navigation
redirect
error with relative URL
#72765
Labels
bug
Issue was opened via the bug report template.
linear: next
Confirmed issue that is tracked by the Next.js team.
locked
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Link to the code that reproduces this issue
https://github.com/Crane101/next-15-relative-redirect-error
To Reproduce
npm run dev
Start
to navigate to/lng/page1
page2
via a server actionCurrent vs. Expected behavior
Expected Behaviour
The app navigates to
/lng/page2
Actual Behaviour
An error is thrown:
TypeError: Invalid URL
Provide environment information
Which area(s) are affected? (Select all that apply)
Navigation
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
The documentation for the redirect function states that the
url
parameter "Can be a relative or absolute path.", which was the case in next 14 - but after upgrading to v15 it seems that only absolute paths will work. From the error I'm guessing that it's using the verbatim relative path to create a newURL
object?Pretty essential for my use case as there does not appear to be a way to access the current url or route parameters from a server action in order to construct an absolute version of the url.
The text was updated successfully, but these errors were encountered: