How can you enable CORS for specific domains in your Node.js application?
- Use the 'Access-Control-Allow-Origin' header
- Set 'CORS: true' in the application settings
- Use the 'enableCORS()' function
- CORS is enabled by default in Node.js
To enable CORS (Cross-Origin Resource Sharing) for specific domains in a Node.js application, you should use the 'Access-Control-Allow-Origin' header in your HTTP response. This header specifies which domains are allowed to access your resources. The other options are not the correct way to enable CORS.
Loading...
Related Quiz
- In what scenario would you need to create a custom error class in Express.js?
- The fs module provides both synchronous and asynchronous methods, identified by the ______ suffix for synchronous methods.
- How can developers handle multiple callback functions to avoid "Callback Hell" in Node.js?
- To include a partial in a Pug template, you use the ______ keyword.
- How can you optimize the rendering performance of template engines like EJS and Pug?