4

Excuse me if im misunderstanding how this should work, im fairly new to the serverless world.

I want to avoid having to explicity list all of my routes in my serverless.yml file so have used the catch all {proxy+}.

When i run sls offline start i see one route listed

ANY | http://localhost:3000/dev/{proxy+}

However, when i try to access for example localhost:3000/dev/test-one i see the following error Cannot GET /%7Bproxy+%7D instead of my expected response.

Am i misunderstanding how to use this?

ps - this works when i explicity list my routes in my yml file, but would like to avoid this if poss.

serverless.yml

service: simply-serverless-web

provider:
  name: aws

plugins:
  - serverless-offline
  - serverless-express

functions:
  app:
    handler: app.handler
    events:
      - http:
          path: /{proxy+}
          method: ANY
          cors: any

app.js

const express = require('serverless-express/express')
const handler = require('serverless-express/handler')
const app = express()

app.all('/test-one', require('./test-one'))
app.all('/test-two', require('./test-two'))
app.all('/test-three', require('./test-three'))

exports.handler = handler(app)

Samuel
  • 2,485
  • 5
  • 30
  • 40

1 Answers1

0

The problem is the stage dev that your are using in the url. I dont think its correct for serverless-offline environments.

It should be (without dev)

ANY | http://localhost:3000/{proxy+}

hope this helps.

Arun Kamalanathan
  • 8,107
  • 4
  • 23
  • 39