I'm trying to fetch data from a mocked response through a web app but I am getting the following message:
Access to XMLHttpRequest at 'http://localhost:3001/api/v1/alarme/nao-lido/2019-06-04' from origin 'http://localhost:8771' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
So, I looked in the terminal and I found the following message:
Error: ENOENT: no such file or directory, open '/home/lssev/dev/bancos/spi/spi-mock/mock/rest/alarme/#nao-lido#{date}/OPTIONS/mock/response.txt'
at Object.openSync (fs.js:440:3)
at Object.writeFileSync (fs.js:1265:35)
at MockController.writeFile (/home/lssev/dev/bancos/spi/spi-mock/node_modules/node-mock-server/lib/Utils.js:153:6)
at MockController._handleMockRequest (/home/lssev/dev/bancos/spi/spi-mock/node_modules/node-mock-server/lib/controller/MockController.js:203:9)
at Layer.handle [as handle_request] (/home/lssev/dev/bancos/spi/spi-mock/node_modules/express/lib/router/layer.js:95:5)
at next (/home/lssev/dev/bancos/spi/spi-mock/node_modules/express/lib/router/route.js:137:13)
at next (/home/lssev/dev/bancos/spi/spi-mock/node_modules/express/lib/router/route.js:131:14)
at next (/home/lssev/dev/bancos/spi/spi-mock/node_modules/express/lib/router/route.js:131:14)
at next (/home/lssev/dev/bancos/spi/spi-mock/node_modules/express/lib/router/route.js:131:14)
at next (/home/lssev/dev/bancos/spi/spi-mock/node_modules/express/lib/router/route.js:131:14)
So, as I saw the "OPTIONS" in the terminal, I thought I should replicate the mocked response for the OPTIONS method. But even with the OPTIONS response mocked endpoint I am getting the CORS problem. At least, I am not getting the message in the terminal again. Just my application that still not being able to fetch the data when requesting through the OPTIONS method.
When I make the same request through Postman, it works. Just through my web application that I am getting into this problem. Any advices that I should follow?
I'm trying to fetch data from a mocked response through a web app but I am getting the following message:
So, I looked in the terminal and I found the following message:
So, as I saw the "OPTIONS" in the terminal, I thought I should replicate the mocked response for the OPTIONS method. But even with the OPTIONS response mocked endpoint I am getting the CORS problem. At least, I am not getting the message in the terminal again. Just my application that still not being able to fetch the data when requesting through the OPTIONS method.
When I make the same request through Postman, it works. Just through my web application that I am getting into this problem. Any advices that I should follow?
My options are: