Comments (8)
it's fixed, test on v6.14.3
from hyper-express.
Sometimes I want to forwards headers but haders response that I want to forward It's include content-length
and it's make app crash
my fixed is delete content-length
before response headers
do you have any recommend ?
from hyper-express.
I try to transfom express to hyper-express but response make me confused
.send
expect onlySendableData = string | Buffer | ArrayBuffer;
.json
all of .send but include objectWhy
.send
not include object and Why I can response string on.json
?
The Response.send()
method is a pure serializable data sending method meaning you can send a String or a pure data form such as Buffer, ArrayBuffer etc etc.
On the other hand, the Response.json()
method does 2 additiona things:
- Sets the
content-type
toapplication/json
- Applies
JSON.stringify(body)
on the provided body meaning It is tailored for sending JSON data properly.
With this mind, It should be clear that doing something like Response.json('Hello')
would work, It is not proper and you are essentially telling the browser that you are sending JSON but are actually sending a string which gets wrapped in JSON.stringify
.
from hyper-express.
Sometimes I want to forwards headers but haders response that I want to forward It's include
content-length
and it's make app crashmy fixed is delete
content-length
before response headersdo you have any recommend ?
Could you provide me a snippet of your code which causes the crash and what the crash you are seeing is?
I am assuming your use case is some sort of proxying but even then hyper-express
supports a custom content-length
header. You may be encountering a bug which may be worth looking into.
from hyper-express.
Sometimes I want to forwards headers but haders response that I want to forward It's include
content-length
and it's make app crash
my fixed is deletecontent-length
before response headers
do you have any recommend ?Could you provide me a snippet of your code which causes the crash and what the crash you are seeing is?
I am assuming your use case is some sort of proxying but even then
hyper-express
supports a customcontent-length
header. You may be encountering a bug which may be worth looking into.
const url = req.params[0]
const body = await req.json()
const { data, headers } = await axios({ ...req, data: body, url })
res.setHeaders(headers)
res.json(data)
when headers from axios response contain content-length
it will crash
My fixed is
delete headers['content-length']
res.setHeaders(headers)
from hyper-express.
What does the crash look like in your console? Could you post the error / stack trace you see or does the application just shut down? Could you also log and provide the headers returned by the axios request along with the length of the data.
If the data property is a string then could you additionally also provide the following: Buffer.from(data).byteLength
Thanks
from hyper-express.
This is headers response from axios
Object [AxiosHeaders] {
date: 'Fri, 17 Nov 2023 13:32:51 GMT',
'content-type': 'application/json',
'content-length': '87',
connection: 'keep-alive',
vary: 'Origin',
'access-control-allow-origin': '*',
'access-control-allow-credentials': 'true',
'burst-ratelimit-limit': '100',
'burst-ratelimit-remaining': '100',
'burst-ratelimit-reset': '1700227971',
'strict-transport-security': 'max-age=15724800; includeSubDomains'
}
This is data response just simple json
{
error: 'message msg_7YoJxFpwkEy6sUx4vvpQjF279jG54by5wEVcC8myr9Wc7STZpprqx not found'
}
It's not show error stack it's only return 502
This page isn’t working
HTTP ERROR 502
from hyper-express.
Could you try upgrading to v6.14.2
to see If your bug is fixed.
from hyper-express.
Related Issues (20)
- Question: Is there support for HTTP3 / QUIC ? HOT 1
- Feature request: swagger HOT 1
- No error thrown if invalid json is sent as body HOT 4
- From version 6.0.0, the response component doesn´t call a close or abort event when the SSE client is closed HOT 1
- Nest-hyper-express-adapter middleware tests failing HOT 4
- Nest-hyper-express instance and local-pipes tests each fail one test HOT 3
- Outdated example of static serving / LiveDirectory HOT 1
- Error: uWS.HttpResponse must not be accessed after uWS.HttpResponse.onAborted callback HOT 1
- Graceful shutdown HOT 4
- Static serving HOT 1
- No error on binding to the same port HOT 1
- No Socket Received From uWebsockets.js likely due to an invalid host or busy port. HOT 2
- Optional Parameter Route HOT 2
- Read JSON as raw HOT 4
- Listen on IPv6 by default HOT 1
- Client certificate validation HOT 1
- v6.15.0 introduces breaking changes with the new server.listen unix socket method HOT 1
- Get Hyper-Express to feature parity with Express HOT 2
- missing Promise return type on shutdown HOT 1
- run on aws lambda HOT 1
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 hyper-express.