Skip to content

Commit

Permalink
Merge 002b3ec into da17f14
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed May 13, 2019
2 parents da17f14 + 002b3ec commit e9e0e8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.txt
@@ -0,0 +1 @@
fixed - Fixed issue with CORS rejecting some callable functions.
12 changes: 10 additions & 2 deletions src/emulator/functionsEmulator.ts
Expand Up @@ -90,9 +90,17 @@ export class FunctionsEmulator implements EmulatorInstance {

hub.use((req, res, next) => {
// Allow CORS to facilitate easier testing.
// Source: https://enable-cors.org/server_expressjCannot understand what targets to deploys.html
// Sources:
// * https://enable-cors.org/server_expressjCannot understand what targets to deploys.html
// * https://stackoverflow.com/a/37228330/324977
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

// Callable functions send "Authorization" and "Content-Type".
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Authorization, Accept"
);
res.header("Access-Control-Allow-Methods", "GET,OPTIONS,POST");

let data = "";
req.on("data", (chunk: any) => {
Expand Down

0 comments on commit e9e0e8a

Please sign in to comment.