You are developing a RESTful API using the http module and need to support CORS. How would you implement CORS headers to handle pre-flight requests in your HTTP server?
- Access-Control-Allow-Origin: *
- Access-Control-Allow-Origin: mydomain.com
- Access-Control-Allow-Origin: true
- Access-Control-Allow-Origin: false
To support CORS in your HTTP server, you should set the Access-Control-Allow-Origin header to the specific domain (e.g., mydomain.com) from which you want to allow requests. Using a wildcard (*) is less secure as it allows any domain, and using true or false is not the correct syntax for this header.
Loading...
Related Quiz
- How do you include partial views in EJS templates?
- When handling errors in an async function, if an error is not caught within the function, it will cause the returned Promise to be in a ________ state.
- You are tasked with optimizing a large-scale application. How would identifying and managing closures help in optimizing the application's memory usage and performance?
- How does denormalization in database schema design affect data redundancy and read performance?
- The async keyword is used before a function to make it return a ________.