Search code examples
javascriptnode.jscorsfly

CORS error while trying to register on my app


I'm new to the world of node.js and backend programmation, and i have a CORS error. i already tried a lot of solutions, but nothing worked for me. I'm using fly.io as server.

Acess to fetch at 'https://<MYFLY.IO URL>/register' from origin 'http://localhost:19006' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

in my code, i already have this :

const cors = require('cors');


const app = express();
app.use(cors());

also, i have this line that shows up when i click register : 2023/07/06 - 16:29:39 | 404 | 910ns | 92.188.66.18 | OPTIONS /register (note : the register code worked well on localhost with nodemon) Do someone have a solution ?


Solution

  • so in fact, there is only with this localhost adress that it doesn't want to work. I tried building my app with expo go, and when i try to register, it doesn't show the CORS error. So, probleme solved ? well, i have another problem now, but i can't post my question here because it is not the same purpose.