Skip to content

Commit 8974fb2

Browse files
committed
Add CORS headers for netlify function, and a script to run funtions locally
1 parent 7c3c93e commit 8974fb2

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"scripts": {
2020
"start": "react-scripts start",
21+
"start:lambda": "netlify-lambda serve src/lambda",
2122
"build": "run-p build:**",
2223
"build:lambda": "netlify-lambda build src/lambda",
2324
"build:app": "react-scripts build",

src/lambda/graphql.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ exports.handler = async (request, context) => {
55
await setup.run();
66
const response = await handleRequest(request, context);
77

8+
response.headers = {
9+
'Access-Control-Allow-Origin': '*',
10+
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
11+
}
812
return response;
913
};

0 commit comments

Comments
 (0)