Rob--W / cors-anywhere

CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request.
MIT License
8.57k stars 5.99k forks source link

The URL is invalid: two slashes are needed after the http(s):. #417

Open ChickenDipper1 opened 2 years ago

ChickenDipper1 commented 2 years ago

Hello,

I have managed to get cors-anywhere setup on my plesk server :) But I seem to be running into an issue I cannot figure out, no matter what URL I use I am presented with the error: " The URL is invalid: two slashes are needed after the http(s):. "

This error shows no matter what URL I try to access for example:

https://mycorsproxy.url/http://google.com https://mycorsproxy.url/https://google.com

Am I missing something obvious here? Any help is much appreciated, thank you!

FelipeGerolomo commented 2 years ago

Same issue! I´m using Azure Cloud

Rob--W commented 2 years ago

You have something else running in front of CORS Anywhere that normalizes the URLs. You should disable that URL rewriting mechanism, to preserve the original request URL. If that is not possible at all, an alternative is to omit the scheme.

From a quick search, it seems that Plesk uses Apache. See https://github.com/Rob--W/cors-anywhere/issues/308

For Azure Cloud, see #82.

ChickenDipper1 commented 2 years ago

Thank you for pointing me in the right direction, turning off nginx proxy mode under nginx settings solves the issue in Plesk.

bulk88 commented 1 year ago

Cloudflare Workers W3C URL JS class has a well known bug that turns "//" into "/" . The CF bug can be googled.

rishi-gurung commented 1 year ago

please guide vercel also

Its-Just-Nans commented 1 year ago

If this is useful for someone

Here is a config for nginx

  1. start your cors-anywhere at localhost:4200
  2. Add this config to the nginx
  merge_slashes off;
  location / {
      proxy_pass          http://localhost:4200/;
  }
prusswan commented 3 months ago

On PaaS platforms (e.g. Heroku) where there is no "nginx" to configure, add a check before https://github.com/Rob--W/cors-anywhere/blob/70aaa22b3f9ad30c8566024bf25484fd1ed9bda9/lib/cors-anywhere.js#L312 (some may choose to fix the parseURL function instead)