I am building serverless application, and want to restrict only 1 url can access to the server.
I tried two ways on serverless.yml
login:
handler: login.login
events:
- http:
path: login
method: post
cors:
origins:
- 'https://admin.test.com'
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
- X-Amz-User-Agent
- Startlower
- Text
- Access-Control-Allow-Headers
- Access-Control-Allow-Origin
And
login:
handler: login.login
events:
- http:
path: login
method: post
cors: true
on login function,
headers: {
"Access-Control-Allow-Credentials": true,
"Access-Control-Allow-Origin" : "https://admin.test.com",
"Content-Type": "application/json",
},
But it is open to public. Anyone has the serverless url can visit, and see the json output.
Which part should I change?