Skip to content

Instantly share code, notes, and snippets.

View yhoungdev's full-sized avatar
🏠
Working from home

sudo whoami yhoungdev

🏠
Working from home
View GitHub Profile
@yhoungdev
yhoungdev / cors.md
Created January 15, 2021 12:47 — forked from jesperorb/cors.md
Handle CORS Client-side

Handle CORS Client-side

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.

Sources : MDN - HTTP Access Control | Wiki - CORS

CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:

Access-Control-Allow-Origin

Keybase proof

I hereby claim:

  • I am yhoungdev on github.
  • I am sudo_whoami (https://keybase.io/sudo_whoami) on keybase.
  • I have a public key whose fingerprint is DCC8 EDB3 BB52 7191 8994 A27A 6206 5FA7 9325 7DCB

To claim this, I am signing this object: