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
Refused to set unsafe header "User-Agent" #982
Comments
Same here. Every single API-Call is generating an "Unsafe Header" error. |
same case me too, and I escaped this case. // typescript
import * as slack from "@slack/web-api";
const client= new slack.WebClient("TOKEN");
delete client["axios"].defaults.headers["User-Agent"]; |
@seratch can I pick up this issue for my first contribution? |
Hi @5tarlxrd, that's nice! As far as I know, there is no other platforms to support. We may want to make the exclusion logic customizable but it'd be totally optional for the initial implementation. |
Related: axios/axios#1231 (comment) @MeilCli Thanks for posting that workaround. |
It doesn't work anymore on Nextjs 12.1.
|
I got it to work successfully, Nextjs 12.5..5, I'm pretty confident it works on previous minor versions, too. |
Yes. Slack doesn't allow their API's to be called on client side AFAIK. |
Exactly. I posted my answer and how to make it work just to help anyone else having this problem. Also as a solution response to your previous answer |
Thanks. I should've posted it myself when I found it but I forgot that I posted something here. Kudos! |
Description
Every time an api call is made i get the error:
Refused to set unsafe header "User-Agent"
I'm using the API package in an electron app.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Packages:
Select all that apply:
@slack/web-api
-> not sure about the others@slack/events-api
@slack/interactive-messages
@slack/rtm-api
@slack/webhooks
Reproducible in:
Steps to reproduce:
Expected result:
The API call is done properly, but since the Slack APIs try to change the user agent (probably to track node version and os version), this throw an error in chrome, since it's not allowing this.
This lead to errors being logged in console for every call. The call itself is not actually compromised, but the console can be flooded with errors.
Actual result:
Error are logged by chrome. I would expect these error not to be logged, being catchable, or having the possibility to prevent the user agent change.
Creating the client in this way:
i.e. forcing it to not have a user-agent is not fixing the problem (apparently the library is still trying to set it as "undefined".
Attachments:
Backtrace:
The text was updated successfully, but these errors were encountered: