In Express, how can you enable Cross-Origin Resource Sharing (CORS) for your API?
- app.use(cors())
- app.enable(cors)
- app.allow(CORS)
- app.cors(true)
To enable Cross-Origin Resource Sharing (CORS) in Express, you should use the cors middleware by adding app.use(cors()) to your application. This middleware allows or restricts cross-origin HTTP requests. The other options are not valid ways to enable CORS in Express.
Loading...
Related Quiz
- In a Cache-Aside strategy, when is the data loaded into the cache?
- The prototype of an instance object in JavaScript is found using the ______ property.
- What is the significance of the 'backpressure' concept in streams in Node.js?
- How does JavaScript handle implicit data type conversion?
- What happens to the prototype chain when using Object.create(null) in JavaScript?