-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
🚀 Feature: Make all requests use a custom User-Agent #24379
Comments
Am I misremembering or do some browsers still refuse to change that header in outgoing requests? Hm are you suggesting that maybe this should be something that's supported out of the box instead of adding it yourself? Haven't heard the request for that before, but happy to leave this up fielding for feedback |
I wasn't aware of such thing, but could be? So far it seems Firefox works fine with the setup I posted above. Not sure about other browsers
Yes, if that's something that more people might be interesting about, it might be a nice idea to have it integrated without needing developers to use a solution like the one we found instead. At least in our case the User-Agent helps us internally in certain scenarios, that's why some people asked us about making backstage use something more specific instead of the default one. |
More generally on the issue: we have the |
That sounds like a good plan to me. Having some kind of utility which simplifies setting custom headers (not only the user-agent, maybe others as well) sounds like a big improvement already! ✨ |
🔖 Feature description
Some developers in our company have suggested us to include the
User-Agent
as part of all the requests that backstage does, whether are internal things or to external services we own.It would be really nice to support this and allow people to set the header easily. Maybe even set the header to "backstage" per default, which might be super helpful in general for tracing.
🎤 Context
Unfortunately, we haven't found any easy way to do such thing. After some research and trials, I came up with a solution which requires adding a middleware in the backend and in the frontend which simply sets the header to the request. This seems to be working for most scenarios (in the frontend it works if you use the
fetchApi
, and in the backend it works always).The only thing that we found out that is not working is related to the
swagger-ui-react
packagee, which uses its own User-Agent header and is not overridden by own custom one.✌️ Possible Implementation
The solution I found locally was the following:
In the backend (new backend system), you need to override the
defaultConfigure
for therootHttpRouter
, and add at the beggining a new middleware which injects the header:For the frontend, the solution was kind of similar. In this case, I needed to override the
fetchApi
definition and add it to our ApiFactory list inside theapis.ts
file:👀 Have you spent some time to check if this feature request has been raised before?
🏢 Have you read the Code of Conduct?
Are you willing to submit PR?
No, but I'm happy to collaborate on a PR with someone else
The text was updated successfully, but these errors were encountered: