Updated OPTIONS method for user function

This commit is contained in:
Michael Mainguy 2023-10-17 12:19:56 -05:00
parent acafe25deb
commit 71128abb5f

View File

@ -3,12 +3,13 @@ import axios from 'axios';
export const handler: Handler = async (event: HandlerEvent, context: HandlerContext) => {
try {
console.log(event.httpMethod);
const origin = event.headers.origin;
if (event.httpMethod == 'OPTIONS') {
return {
headers: {
'Content-Type': 'application/json',
'Allow': 'POST',
'Max-Age': '86400',
'Access-Control-Allow-Methods': 'POST',
'Access-Control-Allow-Origin': origin ? origin : 'https://cameras.immersiveidea.com',
'Access-Control-Allow-Credentials': 'true'
@ -17,7 +18,10 @@ export const handler: Handler = async (event: HandlerEvent, context: HandlerCont
};
}
const baseurl = 'https://syncdb-service-d3f974de56ef.herokuapp.com/';
console.log(baseurl);
const params = JSON.parse(event.body);
console.log(event.body);
const dbKey = params.shareKey;
const password = params.password;