You are developing a web application that needs to make API requests to a server on a different domain. How would you handle CORS to ensure that your web application can interact with the server without any issues?

  • Set up a server-side proxy to forward requests to the other domain.
  • Enable CORS on the server by adding appropriate headers to allow cross-origin requests.
  • Use JSONP for making cross-domain requests.
  • Disable CORS restrictions in the browser settings.
The correct approach is to enable CORS on the server by adding the appropriate headers that allow cross-origin requests. Option A can be a workaround, but it's not the best practice. Option C is an outdated method, and option D is not a recommended security practice.
Add your answer
Loading...

Leave a comment

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