Q38: What is CORS and how do you enable it in Express.js?
CORS (Cross-Origin Resource Sharing) is a browser security feature that restricts cross-origin HTTP requests. In Express, the cors middleware sets appropriate Access-Control-Allow-Origin HTTP headers.
Key Takeaways
- CORS prevents browser client access across different domain origins.
- The
corspackage sets standard access headers automatically.
Knowledge Check
Which HTTP response header allows cross-origin requests?