dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.74k stars 167 forks source link

Route not found #43

Closed albertomr86 closed 6 years ago

albertomr86 commented 6 years ago

Hi.

I love this package. :1st_place_medal:

I'm getting 404 for all endpoints after upgrade to 1.5.4. The cause is the new way to find the path before pass it to the request (https://github.com/dougmoscrop/serverless-http/commit/5fc27b2c3db6f55096075b93ce8544fffe2af8c9#diff-4f98820926ab9e533c0e3ef619e49f66R10)

The follow line always return '/' because the route is in event.path.

event.requestContext.path = event.requestContext.path || '/';

I moved on with this workaround:

'use strict';

import serverless from 'serverless-http';
import app from './app/main';

export const handler = serverless(app, {
  request: function(request, event, context) {
    if (process.env.IS_OFFLINE) {
      event.requestContext.path = event.path || event.requestContext.path;
      request.url = event.requestContext.path;
    }
  }
});

Did I missed something?

OS: Ubuntu 16.04 NodeJS: v6.9.1 serverless: 1.26.1 serverless-offline: v3.18.0

dougmoscrop commented 6 years ago

Sorry about that. Are you saying this happens only with the offline plugin? Or it happens when deployed too?

albertomr86 commented 6 years ago

I haven't tried it in production, right now I'm developing. I think I could try to deploy it and see what happens.

dougmoscrop commented 6 years ago

Should be fixed can you please let me know?

albertomr86 commented 6 years ago

:+1: Thank you. It's working again.