Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST requests ends up with 404 while using web browser #962

Closed
bustedbunny opened this issue Mar 23, 2021 · 3 comments
Closed

POST requests ends up with 404 while using web browser #962

bustedbunny opened this issue Mar 23, 2021 · 3 comments
Labels

Comments

@bustedbunny
Copy link

bustedbunny commented Mar 23, 2021

Screenshot_1
Every time I'm trying to make POST request from browser (chrome), I get 404 error.
But, using any other HTTP Client (I use Nightingale) and sending simple POST request everything works and I get 200 response, and basically everything works fine.

server.on("/post", HTTP_POST, [](AsyncWebServerRequest * request) {
    request->send(200, "text/plain", "Post route");
  });

That's the code I'm using on web page. (I also tried pure JS without jQuery, but it's all the same -> 404)

$(document).ready(function(){
  $("#console").keyup(function(event){
    if (event.which == 13) {
        $.post('/post', $("#console").val() + '\n', function() {
              $("#console").val("");
              });
              }
    });
});
@7doctor7
Copy link

I think that you have a CORS issue.
Try to add default response Headers to your server before init

  DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
  DefaultHeaders::Instance().addHeader("Access-Control-Allow-Headers", "*");

@stale
Copy link

stale bot commented Jun 2, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 2, 2021
@stale
Copy link

stale bot commented Jun 16, 2021

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants