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

See original GitHub issue

I’m trying to make a POST request but I’m still sending OPTIONS as a ‘Request Method’.

Example:

import fetch from 'isomorphic-fetch'

fetch('http://localhost:3000/api/v1/sign_in', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: {
      login: 'test'
    }
})

In Chrome, I can see: Remote Address:127.0.0.1:3000 Request URL:http://localhost:3000/api/v1/sign_in Request Method:OPTIONS Status Code:404 Not Found

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:13

github_iconTop GitHub Comments

17reactions
14113commented, Dec 11, 2015

There is some wired think. When I remove line with:

 'Content-Type': 'application/json'

it works.

So this is correct setup:

import fetch from 'isomorphic-fetch'

fetch('http://localhost:3000/api/v1/sign_in', {
    method: 'POST',
    headers: {
      'Accept': 'application/json'
    },
    body: {
      login: 'test'
    }
})

No OPTIONS request anymore.

12reactions
jmwohlcommented, Jul 7, 2016

Removing the 'Content-Type': 'application/json' works… does anyone know why? Is it a bug, or is this expected?

Read more comments on GitHub >

github_iconTop Results From Across the Web

OPTIONS - HTTP - MDN Web Docs
The HTTP OPTIONS method requests permitted communication options for a given URL or server. A client can specify a URL with this method, ......
Read more >
What is HTTP OPTIONS Method? - ReqBin
The HTTP OPTIONS method is used to describe communication options for the target resource. Browsers send an HTTP OPTIONS request to find out ......
Read more >
Introduction to HTTP OPTIONS Method - Aaron Bos
At a high level, the OPTIONS method is used to determine the communication options available for a specific resource. This means that we...
Read more >
HTTP/1.1: Method Definitions
The OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the ...
Read more >
What is HTTP method OPTIONS? - Medium
The HTTP OPTIONS method is a type of HTTP call that explains what are the options for a target resource such as API...
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