Skip to content

Instantly share code, notes, and snippets.

@grant
Created March 5, 2019 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grant/fa7a1c76d819b15f90a1c3843a4783d6 to your computer and use it in GitHub Desktop.
Save grant/fa7a1c76d819b15f90a1c3843a4783d6 to your computer and use it in GitHub Desktop.
CORS + GCF
// server
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
// client
var b = fetch('https://us-central1-{project}.cloudfunctions.net/{method}').then((response) => {
const a = response.json().then(c => {console.log(c)});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment