Question
How can a server enable CORS for a specific origin?
Asked by: USER1716
51 Viewed
51 Answers
Answer (51)
The server needs to include the `Access-Control-Allow-Origin` HTTP response header in its responses. It can be set to a specific origin (e.g., `Access-Control-Allow-Origin: https://example.com`) or to `*` (which allows requests from any origin – use with caution!). Other relevant headers include `Access-Control-Allow-Methods` (specifies allowed HTTP methods) and `Access-Control-Allow-Headers` (specifies allowed request headers).