Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const CORS = (endpoint: api.Resource, props: AccessControl = {}): api.Resource => {
const mthd = `'${props.method ? props.method.join(',') : 'GET,POST,PUT,DELETE,OPTIONS'}'`
const head = `'${props.header ? props.header.join(',') : 'Content-Type,Authorization,Accept,Origin'}'`
const origin = `'${props.origin || '*'}'`
const mock = new api.MockIntegration({
integrationResponses: [
{
responseParameters: {
"method.response.header.Access-Control-Allow-Headers": head,
"method.response.header.Access-Control-Allow-Methods": mthd,
"method.response.header.Access-Control-Allow-Origin": origin,
"method.response.header.Access-Control-Max-Age": "'600'",
},
selectionPattern: '\\d{3}',
statusCode: '200',
},
],
passthroughBehavior: api.PassthroughBehavior.WHEN_NO_MATCH,
requestTemplates: {
"application/json": "{\"statusCode\": 200}"
},