Encountering the following console error while using the fetch api
:
Error Message in Console:
The Fetch API is unable to load https://... The response to the preflight request failed to pass the access control check: No 'Access-Control-Allow-Origin' header was found on the requested resource. This means that origin 'https://...' does not have permission to access it. The response received an HTTP status code of 404. If you require an opaque response, adjust the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I attempted to resolve this issue by installing the npm cors package
.
npm install cors --save
Following this, I added the following lines to server.js
const cors = require('cors');
app.use(cors());
Setup instructions for Cors package: https://www.npmjs.com/package/cors
Despite these steps, I am still receiving the same preflight request error. Would appreciate any advice on whether additional setup for the cors package is necessary or if there are other actions that need to be taken?