Giter Club home page Giter Club logo

Comments (10)

ijpiantanida avatar ijpiantanida commented on July 1, 2024

Keeping the host header would make tapes specific to where talkback is running (port & host), which is not very useful.

What do you need the host header for?

from talkback.

floydjdx avatar floydjdx commented on July 1, 2024

The system I am working with extracts some information from the host header.

from talkback.

ijpiantanida avatar ijpiantanida commented on July 1, 2024

The host removal only affects tape matching.

The request that will be made to the downstream service will contain its own host header (set to the host property with which you started talkback).

from talkback.

floydjdx avatar floydjdx commented on July 1, 2024

Right, but I can only set one host property when I start talkback and my requests use different host headers depending on the request.

from talkback.

ijpiantanida avatar ijpiantanida commented on July 1, 2024

Talkback only fronts one service at a time, since it wouldn't have information to know where to route a request in case of multiple hosts.

If you're making requests to multiple services and you want to front them with talkback, you should start one talkback instance per service.

Something like this:

const service1 = talback({
  ...baseOpts,
  host: "https://my-service1.com",
  port: 8081,
  path: baseOpts.path + "/service1"
})
service1.start()

const service2 = talback({
  ...baseOpts,
  host: "https://my-service2.com",
  port: 8082,
  path: baseOpts.path + "/service2"
})
service2.start()

from talkback.

floydjdx avatar floydjdx commented on July 1, 2024

That won't work because all requests are meant to be sent to the same service but with different host headers depending on the user whose data is being requested.

from talkback.

brandonc avatar brandonc commented on July 1, 2024

@ijpiantanida I believe @Floydjd is referring to https://github.com/ijpiantanida/talkback/blob/master/src/request-handler.ts#L125 where the host header is deleted during makeRealRequest

I'm debugging an issue whereby removing the host header causes a mismatch for signed requests (aws in this case) which includes the host header value in it's signing. I also looked into node-fetch, your upstream dependency, and found that it does not add a host header. However, according to Mozilla

A Host header must be sent in all HTTP/1.1 requests and serves may respond with 400 for any request that lacks a host header

(source)

I think the right thing to do is maybe to overwrite the host header if it is not set to be the options.host: #51

I can't think of a reason that we wouldn't want a host header in this request under any circumstances. WDYT?

from talkback.

ijpiantanida avatar ijpiantanida commented on July 1, 2024

node-fetch should be adding the host header.

I locally aliased mystrangedomain.com to localhost.
image

What host option are you giving to talkback?

from talkback.

brandonc avatar brandonc commented on July 1, 2024

@ijpiantanida Thanks for looking into this so quickly. You are right! I tested from the fetch side but didn't consider that node http is actually setting the host. Once I checked from the server side as you did I saw the host there.

Theoretically, deleting the host header should work! I'm not sure why it does not but I will debug some more.

from talkback.

brandonc avatar brandonc commented on July 1, 2024

@ijpiantanida I must have made a mistake with a local modified version of talkback. deleting the host header works fine 😬 thank you, again.

from talkback.

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.