I have this proleme for a project with angular and nestjs :
Access to XMLHttpRequest at ‘http://localhost:3000/card’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.
sakli ameni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
So i resolve it by :
1 : npm install –save @nestjs/serve-static in the nest project
2 : import ServeStaticModule in the appModule
rootPath: join(__dirname, ‘..’, ‘client’)
Replace ‘client’ with the path to your Angular build application
3: Add this line to enable CORS headers in the main.ts: app.enableCors();
sakli ameni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.