M
M
MaximPatrushev2021-04-05 11:44:08
Node.js
MaximPatrushev, 2021-04-05 11:44:08

Why does CORS error only occur on prod (heroku)?

When requesting api from localhost, cors works correctly, on prod it gives an error:

Access to XMLHttpRequest at 'https://fit-helper-api.herokuapp.com/login' from origin 'https://fit-helper.herokuapp.com' 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.


Front and api deployed on heroku. This is a pet project, the api is open.
Kors I connect in this way in the index:

...
import * as cors from 'cors';
...
const app: express.Application = express();
...
// middleware
app.use(cors());
...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question