miniflare icon indicating copy to clipboard operation
miniflare copied to clipboard

Invalid headers in fetch requests?

Open katis opened this issue 2 years ago • 1 comments

I'm trying to fetch data from the Finnish transit API's but they return 500 with Miniflare's fetch. The request headers look a bit odd:

image

Using node-fetch for example works fine, and the headers look normal:

image

This should reproduce the problem:

export default {
  async fetch(req, res) {
    const body = {
      query:
        "query StopQuery($id: String!) {\n  stop(id: $id) {\n    name\n    stoptimesWithoutPatterns {\n      scheduledArrival\n      realtimeArrival\n      arrivalDelay\n      scheduledDeparture\n      realtimeDeparture\n      departureDelay\n      realtime\n      realtimeState\n      serviceDay\n      headsign\n    }\n  }\n}",
      variables: { id: "HSL:2214603" },
      operationName: "StopQuery",
    };

    return await fetch(
      "https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql",
      {
        method: "POST",
        body: JSON.stringify(body),
        headers: {
          "content-type": "application/json",
        },
      }
    );
  },
};

katis avatar Mar 12 '22 08:03 katis

Hey! 👋 Apologies for only just getting to this. Which version of Miniflare were you using? Would you be able to try 2.5.0?

mrbbot avatar Jun 09 '22 10:06 mrbbot

Hey! 👋 We haven't heard from you for a while, so I'm going to close this issue. It's likely this was fixed in Miniflare 3, which uses the same workerd runtime as production, so shouldn't have these behaviour mismatches. I'm going to close this as it's unlikely we'll have time to fix this in Miniflare 2. Our development effort is primarily focused on version 3.

mrbbot avatar Nov 07 '23 15:11 mrbbot