Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 3.3.0 does not preserve headers so you can't pass extra headers #1272

Closed
kamran-plt opened this issue Feb 14, 2024 · 12 comments · Fixed by #1304
Closed

version 3.3.0 does not preserve headers so you can't pass extra headers #1272

kamran-plt opened this issue Feb 14, 2024 · 12 comments · Fixed by #1304
Labels

Comments

@kamran-plt
Copy link

kamran-plt commented Feb 14, 2024

If you want to pass for example apiKey then it is not possible atm, The issue is with only Get method

@julada
Copy link

julada commented Feb 15, 2024

If you want to pass for example apiKey then it is not possible atm, The issue is with only Get method

happened to me for version 3.3.1. 3.3.0 works fine.

@attila
Copy link

attila commented Feb 15, 2024

Same here as in #1272 (comment)

In a synthetic Typescript test it works fine (source is transpiled on the fly) but not anymore once the source is built with esbuild for node 18.x.

Need to stick with 3.3.0 until fixed.

@calum-pledge-io
Copy link

Seems likely that this is related to #1248, which was merged in 3.3.1

@chris-gilbert-2
Copy link

I seem to have the same problem with post requests - have checked with version 3.3.1 and 3.3.0 (and 3.2.24 just in case) running on node 18 with axios 1.6.7 - any headers I have set on axios either when creating axios or in the post call get removed. Just double checking for any silly mistakes I've made but wondering if anyone else has problems with post - original issue only mentioned get

@calum-pledge-io
Copy link

I also had issues with POST requests before downgrading to 3.3.0

@chris-gilbert-2
Copy link

Thank-you - I'll double check that I really did downgrade!

@jamesmbourne
Copy link
Owner

Hey all, sorry to hear about this issue. Could you provide some help in reproducing this? I've added tests to ensure that headers are echoed back #1299 but I'm struggling to reproduce the issue.

@calum-pledge-io
Copy link

@attila's comment mentioned that they're using esbuild for bundling and running on nodejs 18, which matches my environment.
@chris-gilbert-2 I see you're running node 18; are you also bundling with esbuild, or using another bundler/not bundling and able to reproduce?

@chris-gilbert-2
Copy link

chris-gilbert-2 commented Mar 12, 2024

Hi @calum-pledge-io

Yes, esbuild. We are running on AWS in a Node 18 lambda environment - here are the relevant scripts in our package.json

  "scripts": {
    "build": "tsc && esbuild src/handlers/app.ts --minify --bundle --target=es2020 --platform=node --sourcemap --outdir=dist",
    "package": "cd dist && zip -r dist.zip . && mv dist.zip .."
  },

our tsconfig.json looks like

{
  "compilerOptions": {
    "target": "ESNext",
    "strict": true,
    "preserveConstEnums": true,
    "useDefineForClassFields": true,
    "noEmit": true,
    "sourceMap": true,
    "module": "ESNext",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": false
  },
  "exclude": ["node_modules"]
}

@jamesmbourne
Copy link
Owner

Thanks for the details @chris-gilbert-2, I managed to reproduce this issue with this information!

Seems like the change in #1248 caused this. I've changed the mechanism to call .set() on the headersr object rather than overwriting it - this should avoid the issues reported of the object not being an instance of the AxiosHeaders class.

Copy link

🎉 This issue has been resolved in version 3.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@attila
Copy link

attila commented Mar 13, 2024

It works like a charm, thank you @jamesmbourne for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants