-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative URL doesn't work with appHandler: "Invalid URL" error #1000
Comments
Wow, lucky #1000! 🌟 |
Hmm. The Pages Router doesn't use the I'll go over the documentation to make sure it's clearer. I haven't used the App Router in production yet, but it doesn't seem like the App Router itself supports relative urls (i.e. all urls seem to be some instance of the |
Ah! If it is unsupported, then a note in the docs to say something like, "to send query params, use literally any URL string with your query params at the end of it (ex: |
### [4.0.4](v4.0.3...v4.0.4) (2024-03-02) #### 🪄 Fixes * **src:** allow relative url strings passed via url shorthand for App Router ([01b86b6](01b86b6)) <sup>closes [#1000](https://github.com/Xunnamius/next-test-api-route-handler/issues/1000)</sup> * **src:** prevent recursive redirection with undici/whatwg fetch ([22bb716](22bb716)) <sup>closes [#993](https://github.com/Xunnamius/next-test-api-route-handler/issues/993)</sup> * **src:** replace `AppRouteUserlandModule` with looser type ([502e666](502e666)) <sup>closes [#1006](#1006), [#1005](https://github.com/Xunnamius/next-test-api-route-handler/issues/1005)</sup>
🎉 This issue has been resolved in version 4.0.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The problem
It seems this commit about normalization of URLs may have broken the ability to use a relative-style
url
param with the app handler because callingnew URL(url)
on a path like"/my-url"
throwsInvalid URL
error (as one would expect it to, sincenew URL()
doesn't accept relative URLs).I was able to get around this easily by providing a dummy beginning of the url as the tests do (e.g.
"ntarh://api/books"
instead of just"/api/books"
), but it doesn't match what the docs say, so it required some digging to figure this out.I noticed the tests include a case with
url: '/my-url'
andpagesHandler
, but not a case for the same url withappHandler
. I believe that's the case that's broken.Reproduction steps
The text was updated successfully, but these errors were encountered: