aws-serverless-express via AWS API gateway asking for authentication even not setup for that

与世无争的帅哥 提交于 2020-01-14 05:34:04

问题


sorry for such 101 question but I'm kinda new with AWS, NodeJS and Express.

I'm setting up a basic serverless API Gateway:

index.js

import AwsServerlessExpress from 'aws-serverless-express';
import App from './src/app';

const server = AwsServerlessExpress.createServer(App);

exports.handler = (event, context) => AwsServerlessExpress.proxy(server, event, context);

./src/app.js

import Express from 'express';
import BodyParser from 'body-parser';
import AwsServerlessExpressMiddleware from 'aws-serverless-express/middleware';

let app = Express();

app.use(BodyParser.json());
app.use(BodyParser.urlencoded({extended: true}));
app.use(AwsServerlessExpressMiddleware.eventContext());

app.get('/status', (req, res) => {
    res.json({ a: "status" });
});

app.get('/', (req, res) => {
    res.json({ a: "root" });
});

export default app;

And on the API Gateway console interface:

What's the problem here? If you need more information let me know please.

Thanks.


回答1:


You're not able to have nested routes and use proxy inside them. You have to choose between use API Gateway routes or manage by yourself everything (all the routes).



来源:https://stackoverflow.com/questions/44133161/aws-serverless-express-via-aws-api-gateway-asking-for-authentication-even-not-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!