From 67940e0d35c1cb5cbbadbdff78e4e87d00a8dae2 Mon Sep 17 00:00:00 2001 From: Andrey Platov Date: Sun, 8 Aug 2021 17:10:36 +0200 Subject: [PATCH] fix lambda CORS Signed-off-by: Andrey Platov --- cloud/app/index.ts | 10 +++++----- dev/prod/.env-prod | 3 +++ dev/prod/src/platform.ts | 4 +++- dev/prod/webpack.config.js | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 dev/prod/.env-prod diff --git a/cloud/app/index.ts b/cloud/app/index.ts index 52cd6af0ac..709a2fca42 100644 --- a/cloud/app/index.ts +++ b/cloud/app/index.ts @@ -106,11 +106,11 @@ const api = new awsx.apigateway.API("login", { const result = handle(body, serverEndpoint.get()) return { statusCode: result.statusCode, - // headers: { - // "Access-Control-Allow-Headers" : "Content-Type", - // "Access-Control-Allow-Origin": "*", - // "Access-Control-Allow-Methods": "GET,HEAD,POST" - // }, + headers: { + "Access-Control-Allow-Headers" : "Content-Type", + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "OPTIONS,POST" + }, body: result.body } }, diff --git a/dev/prod/.env-prod b/dev/prod/.env-prod new file mode 100644 index 0000000000..e9652c7bfa --- /dev/null +++ b/dev/prod/.env-prod @@ -0,0 +1,3 @@ + + +APP_ACCOUNTS_URL=https://ftwm71rwag.execute-api.us-west-2.amazonaws.com/stage/ diff --git a/dev/prod/src/platform.ts b/dev/prod/src/platform.ts index 5c952b2a74..d96058f9e9 100644 --- a/dev/prod/src/platform.ts +++ b/dev/prod/src/platform.ts @@ -36,8 +36,10 @@ import { setMetadata } from '@anticrm/platform' export function configurePlatform() { + console.log(process.env.APP_ACCOUNTS_URL) + // setMetadata(login.metadata.AccountsUrl, 'https://ftwm71rwag.execute-api.us-west-2.amazonaws.com/stage/') - setMetadata(login.metadata.AccountsUrl, '/api') + setMetadata(login.metadata.AccountsUrl, process.env.APP_ACCOUNTS_URL) // if (process.env.CLIENT === 'dev') addLocation(clientId, () => import(/* webpackChunkName: "client-dev" */ '@anticrm/dev-client-resources')) diff --git a/dev/prod/webpack.config.js b/dev/prod/webpack.config.js index cbd018c7f0..821f603364 100644 --- a/dev/prod/webpack.config.js +++ b/dev/prod/webpack.config.js @@ -152,7 +152,7 @@ module.exports = { new MiniCssExtractPlugin({ filename: '[name].css' }), - new Dotenv() + new Dotenv({path: prod ? '.env-prod' : '.env'}) ], devtool: prod ? false : 'source-map', devServer: {