-1

Since the latest Chrome update, when developing my React app locally I am getting a warning in Chrome, as per the title that links me to https://www.chromestatus.com/feature/5629709824032768

The problem seems to be that I am developing on localhost, but I am calling my development domain https://dev-api.example.com

My API allows access for all requests, and this wasn't an issue before 5th March which is when the above article was updated.

I can see the requests going out in the Network tab, but I am unable to see the responses or log them out. As you can see below, it shows the truncated response, but clicking the dropdown arrow doesn't do anything

enter image description here

My code to call the API is pretty straight forwards too

return axios({
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${jwt}`
      },
      data,
      url: `${process.env.REACT_APP_API}${url}`,
    }).then(response => {
      if(process.env.NODE_ENV === "development") console.log(`POST:`, response);

      if (response && response.data.success) return response.data.data || response.data.success;
      if(response.data.errors[0] === "E_UNAUTHENTICATED") {
        return window.location = '/login?msg=Session Expired';
      }
      if(response.data.errors) {
      return Promise.reject(new Error('An unknown error occurred'));
    }).catch(e => {
      return Promise.reject(e.message);
    })
K20GH
  • 4,944
  • 16
  • 60
  • 94
  • You should quote the **full** error message (which will probably tell you that the browser is expecting JSON and getting HTML or something similar). Then look at the Network tab to see what is wrong with the response (is it just the Content-Type header? Is it the entire response is wrong?). Then fix the error on the server side code which generates the response. – Quentin Apr 02 '19 at 10:56

1 Answers1

-1

You can start chrome with cors turned off, see here: [Disable same origin policy in Chrome

If you check that link you can see that you can actually make a custom bookmark to fire up chrome with the correct security settings for your development that will function along side your regular chrome windows.