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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *