next-runtime
next-runtime copied to clipboard
[Bug]: Invalid URL error when handling rewrite
Steps to reproduce
A customer forked the zones example from Next.js which uses rewrites to stitch together multiple micro-sites into a single site using the following config:
module.exports = {
async rewrites() {
return [
{
source: "/blog",
destination: "https://with-zones-blog.netlify.app/blog",
},
{
source: "/blog/:path*",
destination: "https://with-zones-blog.netlify.app/blog/:path*",
},
];
},
};
This example is deployed at https://silly-edison-c456ac.netlify.app if you navigate to https://silly-edison-c456ac.netlify.app/blog you will see the following error:
{"errorType":"TypeError","errorMessage":"Invalid URL: https,http://with-zones-blog.netlify.app/blog","trace":["TypeError [ERR_INVALID_URL]: Invalid URL: https,http://with-zones-blog.netlify.app/blog"," at onParseError (internal/url.js:258:9)"," at new URL (internal/url.js:334:5)"," at new URL (internal/url.js:331:22)"," at Runtime.handler (/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:137:22)"," at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"]}
A link to a reproduction repository
https://github.com/chrishannaby/with-zones-netlify-redirect
Plugin version
4.0.0-rc.0
More information about your build
- [ ] I am building using the CLI
- [ ] I am building using file-based configuration (
netlify.toml
)
What OS are you using?
No response
Your netlify.toml
file
`netlify.toml`
[build]
environment = { NETLIFY_USE_YARN="true" }
command = "yarn build"
publish = ".next"
[dev]
command = "yarn dev"
publish = ".next"
[[plugins]]
package = "@netlify/plugin-nextjs"```
</details>
### Relevant log output (or link to your logs)
<details>
<summary>Build logs</summary>
Paste logs here
</details>
I am having the same problem. @chrishannaby Did you you found any solution for this so far?
There have been significant changes in the plugin since I reported this issue but I have not validated whether they fixed this for me yet. Can you share more details on your issue @k88manish ? Site URL etc
I tried to use the rewrite on my job on an internal site. So I couldn't share that but I will try it on something on my GitHub but the problem is very same even with latest plugin version
it is definitely not fixed. Also surprising this is still an issue.
@chrishannaby
I've deployed the two sites (home and blog) in the example repo you supplied, and I can confirm that the blog shows up properly without error. The only changes I made were updating the next-runtime version to @netlify/[email protected]
home
site: https://zones-home-test.netlify.app/
Closing as this appears to be resolved.