无服务器离线和快速路由无法正常工作

时间:2018-03-28 09:03:34

标签: javascript node.js express serverless

我的代码中有2条路线,但总是拨打第一条路线。 我尝试了几次尝试,但看不出我做错了什么。如何拨打第二条路线?我的代码是:

index.js

const express = require('express');
const serverless = require('serverless-http');
const app = express()

//first route
//always call this
app.get('/', function (req, res) {
	res.send('Hello World!')
})

//the second route
//never call this
app.get('/test', function (req, res) {
	  res.send('Hello Test!')
})

module.exports.handler =  serverless(app);

serverless.yml

# serverless.yml

service: Test

plugins:
  - serverless-offline 
    
provider:
  name: aws
  runtime: nodejs6.10
  environment:
    WEBHOOK_URL: ""

functions:
  app:
    handler: index.handler
    events:
      - http: ANY /
      - http: 'ANY {proxy+}' 

0 个答案:

没有答案