-1

I am building a web app with react, and when I try to request to my API using a custom method (AUTH) it says I requested with the OPTIONS method. here is my code

    await fetch(apiUrl + '/' + formState.values.email + '/' + formState.values.password,{method: 'AUTH', body: ""}).then(async (res) => {
      if (res.status === 200) {
        await res.json().then((data) => {
          localStorage.setItem('user_data', JSON.stringify(data.user_data));
          localStorage.setItem('user_auth', JSON.stringify(data.user_auth));
        });
      }
    }).then(() => {
      router.history.push('/');
    })

but in by backend service it says different, here is the screenshot of my backend enter image description here

Can Anyone help me with this problem ?

Mohamad Shiralizadeh
  • 7,153
  • 5
  • 52
  • 78
Mufid Zukh
  • 21
  • 4
  • 1
    Does this answer your question? [Why is an OPTIONS request sent and can I disable it?](https://stackoverflow.com/questions/29954037/why-is-an-options-request-sent-and-can-i-disable-it) – goto1 Feb 16 '20 at 12:32
  • your question is not clear could you show the log and response json as well? – molood ayat Feb 16 '20 at 12:32

1 Answers1

1

You should enable CORS in your Server Application to handle origin header for external requests.

Mohamad Shiralizadeh
  • 7,153
  • 5
  • 52
  • 78