next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

[Bug]: Invalid URL error when handling rewrite

Open chrishannaby opened this issue 3 years ago • 4 comments

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>

chrishannaby avatar Dec 07 '21 01:12 chrishannaby

I am having the same problem. @chrishannaby Did you you found any solution for this so far?

k88manish avatar Apr 18 '22 10:04 k88manish

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

chrishannaby avatar Apr 18 '22 18:04 chrishannaby

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

k88manish avatar Apr 21 '22 05:04 k88manish

it is definitely not fixed. Also surprising this is still an issue.

pdpwebsecurify avatar Jun 10 '22 23:06 pdpwebsecurify

@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.

sarahetter avatar Sep 21 '22 14:09 sarahetter