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)
hey @sami616 just glancing over your issue, this might be a question for serverless-express.
turns out this works with latest stable version of serverless-offline (removing /dev from the url) it seems the next npm tagged version of the package breaks this {proxy+} functionality.
Having the same issue. Which version are you using to resolve the issue?
@akarale "serverless": "^1.61.3"
I am facing the same issue as I am trying to test locally some Angular + Express setup with Serverless. Using these set of plugins:
"devDependencies": {
"serverless-api-compression": "^1.0.1",
"serverless-apigw-binary": "^0.4.4",
"serverless-dotenv-plugin": "^2.3.2",
"serverless-offline": "^6.0.0-alpha.67",
"serverless-plugin-typescript": "^1.1.9"
}
But unfortunately, while trying to load assets from the localhost, the server.js file is unabled to find those. I will provide another ticket to provide more details but I belive it is related to this issue.
@sami616 @dnalborczyk
I think this is the same issue that I ran into.
It looks like 6.0.0-alpha.61 introduced an issue where the path that is defined in the serverless.yml is being set as the _path property on startup and then being used for every subsequent request.
For my setup I had /{any+} as the path in the yml file, and every request the event.path property was set to /{any+}.
I've submitted a PR that I think fixes the issue but it may have side effects that I'm not aware of.
Edit: typo
i have this problem too with alpha version
@dnalborczyk Can you fix this or do you want me to do it?
Hi @dherault,
I have submitted a PR that I think will resolve this issue (see above). The path property is being set to whatever the path is defined in the .yml file not the request path. Hence it works if the paths are defined in the .yml but not if using /{proxy+} or /{any+} etc
@sami616 Is this still and issues with v6?
@jadams88 just tried and v6 seems to fix it, brilliant, thank you!
Excellent, glad it鈥檚 working for you.
This issue can probably be closed now.