Cross-origin resource sharing (CORS) is a mechanism that allows resources to be requested from another domain. Under the hood, Nest makes use of the Express cors package. This package provides various options that you can customize based on your requirements.
To enable CORS, call the
enableCors() method on the Nest application object.
enableCors() method takes an optional configuration object argument. The available properties of this object are described in the official CORS documentation.
Alternatively, enable CORS via the
create() method's options object. Set the
cors property to
true to enable CORS with default settings. Alternatively, pass a CORS configuration object as the
cors property value to customize its behavior.