dherault / serverless-offline

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

Any way to deactivate http-proxy ? #1669

Open erwan-joly opened 1 year ago

erwan-joly commented 1 year ago

I'm searching for a way to deactivate http-proxy on dev. So http proxy do not seems to work for my resources in serverless offline so i turned resourceRoutes to false. My idea is my lambda is actually going to serve the right data but on dev only. Unfortunately it only works if i comment out the events or else i get conflicting routes...

image

My current way to deal with this is to comment the code and get my ci/cd to uncomment it... That's pretty ugly. I'm wondering if there is anyway to make it works without comments ?

pkit commented 6 months ago

Something like that will probably work:

plugins:
  - serverless-plugin-ifelse

custom:
  serverlessIfElse:
    - If: '"${env:IS_OFFLINE, "0"}" == "1"'
      Exclude:
        - functions.marketracoon-spa.events[0]
        - functions.marketracoon-spa.events[1]
        - functions.marketracoon-spa.events[2]

needs IS_OFFLINE=1 sls offline start