Comments (3)
I just submitted a PR for this. #67 Hopefully it'll roll out soon. In the meantime, you can fiddle with a field overwrite ahead of the handler call in AWS. The queryStringParameters field in the event should be a subset of the multiValueQueryStringParameters field, so you can || them or just overwrite the queryStringParameters directly.
//index.js
const serverless = require('serverless-http')
const app = require('./app')
let server = serverless(app, {
callbackWaitsForEmptyEventLoop: false,
request: function (request, event, context) {
// ...
},
response: function (response, event, context) {
// ...
}
})
app.setup(server)
module.exports = {
handler: async (event, context) => {
event.queryStingParameters = event.multiValueQueryStringParameters
return server(event, context)
}
}
I have a fork with functioning code for AWS Lambda / node at least here: https://github.com/jamesvillarrubia/serverless-http. Feel free to npm install it directly.
from serverless-http.
Thanks @jamesvillarrubia for pointing me in the right direction.
Note for anyone trying to do this (for application load balancer at least) you need to convert the querystrings / headers on the way in and the headers on the way out.
eg:
module.exports = {
handler: (event, context) =>
event = util.serverlessTransformMultiValuesIncoming(event)
event = util.serverlessCleanQueryStringParameters(event)
server(event, context)
.then (res) =>
res = util.serverlessTransformMultiValuesOutgoing(res, event)
res
}
Keys to transform inbound are: multiValueQueryStringParameters->queryStringParameters
and multiValueHeaders->headers
. Outbound there are only headers so headers->multiValueHeaders
from serverless-http.
Released in 1.9.0
from serverless-http.
Related Issues (20)
- Using this library with AWS function URLs? HOT 3
- body-parser middleware not triggering in Express 5/body-parser 2.x HOT 2
- Cannot work with graphql, express-graphql or graphql-http
- Multiple `set-cookie` don't end up in the final response when an ALB is the trigger
- Integration with websockets HOT 1
- gRPC connect-es support
- Double logging since v3.1.1 HOT 1
- Is there a way to disable or replacing logging? HOT 1
- Xmlrpc support ? HOT 7
- How to properly wrap the http.createServer? HOT 4
- Streaming response HOT 5
- Use with Serverless Dashboard V2.0 and CLI V3 HOT 4
- {"message":"Missing Authentication Token"}
- Support Elysia.js
- Buffer in request.body
- Catch-all error handling with API GW?
- Is this repo still being maintained? HOT 1
- Cache - help or insights
- Error Using serverless/koa with serverless V4.1.11
- query string 的处理和阿里云服务器不符
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-http.