Closed alleksei37 closed 1 year ago
LGTM ✅
Ideally, we should also include the current version of the package as part of the User-Agent header but it would require some more work like adding an additional build step to run a tokenizer to set the version after TS compilation.
Or, we could just parse the version on runtime from package.json, no?
LGTM ✅
Ideally, we should also include the current version of the package as part of the User-Agent header but it would require some more work like adding an additional build step to run a tokenizer to set the version after TS compilation.
Or, we could just parse the version on runtime from package.json, no?
Yeah, I think we could do that too but during build time only since we don't have package.json at runtime. 🤔
Why is package.json not available during runtime?
Why is package.json not available during runtime?
I mean, when a browser runs this client which is bundled with the rest of the app there is no package.json at that point. But if you meant to parse package.json at build time and statically set the version in the client's code then it should work perfectly! Sorry for the possible misunderstanding here.
@alleksei37 I’m confused. This is typegen you’re adding the user agent header for. It’s a command line tool. Doesn’t run in the browser.
This change doesn’t affect user agent in the actual openapi client instance
@alleksei37 I’m confused. This is typegen you’re adding the user agent header for. It’s a command line tool. Doesn’t run in the browser.
This change doesn’t affect user agent in the actual openapi client instance
Oh, yes! You are 100% right! I made a wrong mental connection between the client in the browser and this package! Please disregard my previous comment about the issues with parsing package.json 🤦🏻♂️
@anttiviljami I'm sorry for pinging you again, but when this PR can be merged? It looks like I don't have permission for that. Thanks!
Hi @alleksei37 ! Thanks for your work, I'm ready to merge ✅
Typegen module is not using User-Agent header which may cause issues with some proxies that require this header. The content of the header is not that important. Having the User-Agent header also helps to distinguish Typegen requests during CI/CD build step from all other client side requests. I believe that Typegen can be considered as a user agent. The definition of the User Agent can be found here: https://www.rfc-editor.org/rfc/rfc9110.html#name-user-agents Per RFC 9110 (HTTP Semantics) A user agent SHOULD send a User-Agent header field in each request unless specifically configured not to do so. https://www.rfc-editor.org/rfc/rfc9110.html#name-user-agent
P.S. Ideally, we should also include the current version of the package as part of the User-Agent header but it would require some more work like adding an additional build step to run a tokenizer to set the version after TS compilation.