CORS

A way to allow Frontend interaction.

Quoting the official NestJS Docs:

Cross-origin resource sharing (CORS) is a mechanism that allows resources to be requested from another domain.

We can then notice that enabling CORS may make sense when we have an actual Frontend to interact with our Backend. To enable CORS, go to the src -> main file and here, after instantiating the application but before listening to port 3000, enable it.

app.enableCors();

You can check the official CORS documention (same link as in the NestJS Docs) to see the available options for configuring it, like which domains should be accepted, etc.

Commit - Enabling cors

Last updated