question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request Method:OPTIONS not making POST

See original GitHub issue

Hi there,

I have a mapping set up to return 200 when a OPTIONS request is made. It returns the 200 but then doesn’t continue with the original request.

Basically I make a POST request to a service ( Which I have mapped and mocked) bu the pre-flight request is mapped returns 200 but then that’s it. It never makes the POST.

Any ideas or help would be great. Here is my OPTIONS mapping.

{
    "request": {
        "url": "/service/security/getDetailsInfo",
        "method": "OPTIONS"
    },
    "response": {
        "status": 200,
        "headers": {
            "Access-Control-Allow-Origin": "http://localhost:8080",
            "Access-Control-Allow-Headers": "OWASP_CSRFTOKEN, X-Requested-With",
            "Access-Control-Allow-Methods": "GET, POST"
        }
    }
}

and here is the POST mapping

{
"request" : {
    "url" : "/service/security/getDetailsInfo",
    "method" : "POST",
    "headers" : {
      "Accept" : {
        "equalTo" : "*/*"
      }
    }
  },
  "response" : {
    "status" : 200,
    "bodyFileName" : "details.json",
    "headers" : {}
  },
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
LouisMazelcommented, Jan 4, 2018

If someone is interested, I have the solution for all your OPTIONS requests :

{ "request": { "urlPathPattern": ".*", "method": "OPTIONS" }, "response": { "status": 200, "headers": { "Access-Control-Allow-Origin": "http://localhost:8080", "Access-Control-Allow-Headers": "OWASP_CSRFTOKEN, X-Requested-With, Authorization", "Access-Control-Allow-Methods": "GET, POST" } } }

Secret is : "urlPathPattern": ".*" for all requests

❤️

2reactions
pkearney13commented, Jul 26, 2017

Hey, I can’t remember exactly what they were but it was something like this.

{ "request": { "url": "*", "method": "OPTIONS" }, "response": { "status": 200, "headers": { "Access-Control-Allow-Origin": "http://localhost:8080", "Access-Control-Allow-Headers": "OWASP_CSRFTOKEN, X-Requested-With", "Access-Control-Allow-Methods": "GET, POST" } } }

Basically, I just needed to make this mapping a kind of catch all for all OPTIONS requests regardless of the url. Hope this makes sense.

If you are having trouble figuring out what gets returned you could try the recording functionality and capture all the correct headers. That’s what I did.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I getting an OPTIONS request instead of a GET ...
10 Answers 10 · It uses methods other than GET or POST. · It sets custom headers in the request (e.g. the request...
Read more >
Why is my browser sending an OPTIONS HTTP request ...
As you can see, the POST method is never sent and only a method called OPTIONS is sent to the endpoint. The response...
Read more >
Request Method:OPTIONS not making POST #650 - GitHub
Hi there,. I have a mapping set up to return 200 when a OPTIONS request is made. It returns the 200 but then...
Read more >
Why Is an OPTIONS Request Sent? - Baeldung
Learn why an OPTIONS HTTP request is sent. ... Sometimes, we're not able to make the request a same-origin request or a simple...
Read more >
OPTIONS - HTTP - MDN Web Docs - Mozilla
POST , GET , and OPTIONS are permitted methods for the URL. (This header is similar to the Allow response header, but used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found