Skip to content

Commit

Permalink
Merge e854809 into 73e417f
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed May 13, 2019
2 parents 73e417f + e854809 commit 4511a49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
@@ -1 +1,2 @@
fixed - Functions emulator no longer watches node_modules files.
fixed - Fixed issue with CORS rejecting some callable functions.
fixed - Functions emulator no longer watches node_modules files.
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 4511a49

Please sign in to comment.