Embedio: 405 (Method Not Allowed)

Created on 7 Sep 2018  路  14Comments  路  Source: unosquare/embedio

Is your feature request related to a problem? Please describe.
When client sends POST request with Authorization header, the client's method changes to OPTIONS and the server return's the 405 Method Not Allowed. But at the same time, when the client sends the POST request without any headers, server is returning Status 200 OK.

Describe the solution you'd like
When client will send POST request with Authorization header token, the server should return Status 200 OK.

Describe alternatives you've considered
We have tried to enable CORS on the server-side using: Server.EnableCors();

Also, on the client side, we have tried to enable credentials

help wanted v1.x v2.x

Most helpful comment

Please try the latest nuget v1.16.1.

All 14 comments

What authorization module are you using?

We are not using any modules, we are writing authorization header for the post request.

But where are you expecting to receive the POST? Are you using a WebAPI controller?

    Server.RegisterModule(new WebApiModule());
    Server.Module<WebApiModule>().RegisterController<Test>();

    public class Test : WebApiController
    {
        [WebApiHandler(HttpVerbs.Post, "/api/test")]

Yes

I'm running EmbedIO Sample project and using the echo POST method from there I got no problems adding an authorization header:

image

Yes, if you send requests through Rested / Postman, then everything is fine, but if you send a query simply from the index.html or localhost & server file, then that problem, here is an example of sending, also tried through fetch

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">

  <title>Document</title>
</head>

<body>
  <input type="file" onchange="Get('http://localhost:8080/api/user?uid=0')">

  <script>
    function Get(url) {
      const Request = new XMLHttpRequest();

      Request.open("GET", url, false);
      Request.setRequestHeader("Authorization", "Basic sfddsfsdf");
      Request.send(null);

      return Request.responseText;
    }
  </script>
</body>

</html>

Is index.html in the same domain (localhost:8080)?

No, API: 8080 & Index: 8181

Our API will stand on another server, and the site on the other.

Ok, let me test with CORS then.

I found the issue, CORS module is not responding correctly.

Please try the latest nuget v1.16.1.

Yes, everything works, thank you

Cool. Closing issue.

馃専 Please star this project if you find it useful!

Confirming that now with 1.16.1 things work for me. Earlier report of troubles was incorrect, an error on my side. I deleted that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simohr picture simohr  路  5Comments

madnik7 picture madnik7  路  5Comments

Dewyer picture Dewyer  路  7Comments

Dewyer picture Dewyer  路  8Comments

erossini picture erossini  路  5Comments