Form Submit shows strange error in console Form Submit shows strange error in console mongoose mongoose

Form Submit shows strange error in console


before a CORS request is sent to the server, clients will always send this "OPTIONS" request as a "preflight request", soliciting supported methods from the server.

This request being blocked may be an indicator of a wrong CORS configuration or an explicit block of all "OPTIONS" requests from the server. (CORS needs to be configured on the server as well).

More information can be found here


It seems that this is a known nodejs issue that is still open.

Based on the open github, seems that the best recommendation is to try something like this:

you need to allow both:

// Http.OPTIONS method for request that is hitting " apiUrl =https://127.0.0.1:3000/login".// Allow CORS like below:res.header('Access-Control-Allow-Origin', '*');res.header('Access-Control-Allow-Headers', 'content-type');res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');

Another great idea is to use the angular proxy settings for local development so that you will not need to add CORS for localhost at all.

Very good guidance in this SO answer here on setting up a proxy for angular If this work, then you can make 100% sure that it is indeed a CORS problem.


To handle CORS in express you dont need to add any dependency.Notice that http://localhost:4200 is you angular app.

This worked for me:

//Add here whatever route you are using for the api.app.use('/api', (req, res, next) => {  //Where http://localhost:4200 is the angular app  res.header('Access-Control-Allow-Origin', 'http://localhost:4200'),  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');  next();})

Note:This goes after the place where you import the routes and before where you use them. kind of like:

const apiRouter = require('./app_api/routes/api_routes');//The code i posted hereapp.use('/api', apiRouter);