Giter Club home page Giter Club logo

Comments (8)

7elven avatar 7elven commented on September 23, 2024 1

it's fixed, test on v6.14.3

from hyper-express.

7elven avatar 7elven commented on September 23, 2024

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.

kartikk221 avatar kartikk221 commented on September 23, 2024

I try to transfom express to hyper-express but response make me confused

.send expect only SendableData = string | Buffer | ArrayBuffer; .json all of .send but include object

Why .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 to application/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.

kartikk221 avatar kartikk221 commented on September 23, 2024

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 ?

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.

7elven avatar 7elven commented on September 23, 2024

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 ?

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.

    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.

kartikk221 avatar kartikk221 commented on September 23, 2024

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.

7elven avatar 7elven commented on September 23, 2024

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.

kartikk221 avatar kartikk221 commented on September 23, 2024

Could you try upgrading to v6.14.2 to see If your bug is fixed.

from hyper-express.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.