I created a simple api (using serverless) which is protected by an apikey (when deployed via $ serverless deploy
). However, for local development ($ serverless offline
) I do not want to use an api key. How can I disable this for local only?
This is my serverless.yml
:
service: my-service
frameworkVersion: "3"
provider:
name: aws
runtime: nodejs16.x
region: eu-central-1
apiGateway:
apiKeys:
- name: my-apikey
value: ${ssm:my-apikey}
functions:
myfunc:
handler: src/v1/myfunc/index.get
events:
- http:
path: /v1/myfunc
method: get
private: true
plugins:
- serverless-esbuild
- serverless-offline
- serverless-dotenv-plugin
Note: I am aware that I could simply set private: false
when doing local development but this is quite tedious when there is a long list of functions.
The solution was to use the --noAuth
option:
serverless offline --noAuth