diff --git a/crabfit-backend/index.js b/crabfit-backend/index.js index 9100ca9..f79daea 100644 --- a/crabfit-backend/index.js +++ b/crabfit-backend/index.js @@ -16,19 +16,21 @@ const updatePerson = require('./routes/updatePerson'); const app = express(); const port = 8080; +const corsOptions = { + origin: process.env.NODE_ENV === 'production' ? 'https://crab.fit' : 'http://localhost:3000', +}; const datastore = new Datastore({ keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS, }); -app.use(cors({ - origin: process.env.NODE_ENV === 'production' ? 'https://crab.fit' : 'http://localhost:3000', -})); app.use(express.json()); app.use((req, res, next) => { req.datastore = datastore; next(); }); +app.options('*', cors(corsOptions)); +app.use(cors(corsOptions)); app.get('/', (req, res) => res.send(`Crabfit API v${package.version}`)); diff --git a/crabfit-backend/swagger.yaml b/crabfit-backend/swagger.yaml index 5dee8c1..750b507 100644 --- a/crabfit-backend/swagger.yaml +++ b/crabfit-backend/swagger.yaml @@ -4,6 +4,9 @@ info: description: "Compare and align schedules to find a time that works for everyone" version: "1.0.0" host: "api-dot-crabfit.appspot.com" +x-google-endpoints: +- name: "api-dot-crabfit.appspot.com" + allowCors: true schemes: - "https" produces: