dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.19k stars 796 forks source link

API keys not detected if only strings #1661

Closed andersem closed 8 months ago

andersem commented 1 year ago

Bug Report

API keys not detected if only strings

Current Behavior

We used the --apiKeys CLI option removed in https://github.com/dherault/serverless-offline/pull/1585/files.

We were already using provider.apiGateway.apiKeys in our serverless.yml, and the same key was set there as previously in --apiKey, so in theory, serverless-offline should still pick it up, but it didn't.

It turns out that getApiKeysValues only accepts objects, while simple strings should also be allowed.

Sample Code

provider:
  name: aws
  apiGateway:
    apiKeys:
      - ${env:API_KEY}

Expected behavior/code

serverless-offline should use the provided API key.

Possible Solution

Amend getApiKeysValues

Additional context/Screenshots