hyperobject / crossorigin.me

A CORS proxy for everyone.
http://crossorigin.me
MIT License
679 stars 132 forks source link

405 METHOD NOT ALLOWED #88

Open mmellado opened 7 years ago

mmellado commented 7 years ago

I'm trying to make a call using fetch but no matter what site I try to hit I get a 450 Method not allowed.

I'm using it this way:

const options = {
  "method": "GET",
  "headers": {
     "accept":  "application/json",
     "content-type": "application/json"
   }
};

fetch('http://crossorigin.me/http://google.com', options)
        .then(res => res.text())
        .then(res => console.log(res));

output:

VM912:2 OPTIONS http://crossorigin.me/http://google.com 405 (Method Not Allowed)

(index):1 Fetch API cannot load http://crossorigin.me/http://google.com. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3003' is therefore not allowed access. The response had HTTP status code 405. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Is this a bug or am I just not using crossorigin.me correctly?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/42908329-405-method-not-allowed?utm_campaign=plugin&utm_content=tracker%2F12536595&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12536595&utm_medium=issues&utm_source=github).
hyperobject commented 7 years ago

Couldn't replicate that - could you give me some more details on the context you're using that code in?

mmellado commented 7 years ago

It's a frontend application using GitHub's Fetch polyfill to make the request. This happens both when trying to make the call from my script or when copying the code into the developer tool's console and triggering it from there. This is currently being run from a local development node server at localhost:3000

Banderi commented 7 years ago

I'm getting the same error in response for other requests. E.g.:

$.post("http://crossorigin.me/http://google.com");
...
POST http://crossorigin.me/http://google.com 405 (Method Not Allowed)
XMLHttpRequest cannot load http://crossorigin.me/http://google.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://semicolon.altervista.org' is therefore not allowed access. The response had HTTP status code 405.
hyperobject commented 7 years ago

@Banderi That's because POST isn't implemented, so it's not allowed.

Banderi commented 7 years ago

You mean $.post isn't, or the POST method altogether isn't? In any case, without 50% of the ajax working I find this service quite lacking.. don't get me wrong, I appreciate the free service, but I thought the whole point would be to proxy simple ajax requests.