Closed celestialkylin closed 3 months ago
May I add the custom header feature to the Horizon Server? Working with some endpoint providers requires authorization with a custom header
@celestialkylin can you write an integration test that confirms the Horizon behavior fails before you code change and passes afterward? that would help validate this issue! I feel like people have had success setting custom headers in the past, but maybe they had to use axios hooks.
You can reference/extend test/integration/client_headers_test.js
.
Apologies for the lack of rigor, fixed the compile error and added a test in client_headers_test.js.
By the way, when I wrote the test script, I encountered an issue where server.listen(port, (err) => {}) listens on IPv6 by default. This caused a connection timeout when I running the test. Could this be modified to increase ease of use?
@celestialkylin ah shoot, we need all commits to be signed to merge; can you get that set up? Happy to help if you have Qs.
@celestialkylin ah shoot, we need all commits to be signed to merge; can you get that set up? Happy to help if you have Qs.
Ah, I am a GitHub beginner. I have recommitted a signed version now
Thank you, no need to apologize! The IPv6 issue is odd, I'll take a look at that. What Node version were you using? Maybe that's a differentiator.
My node version is v18.20.3, there is a document here "https://nodejs.org/api/net.html#serverlisten", it says:
"If host is omitted, the server will accept connections on the [unspecified IPv6 address] (::) when IPv6 is available, or the (0.0.0.0) otherwise."
It's odd to compare the length with 0. In the original code, I need to do this to add a custom header:
let custom_header = {}; let server = new Server('https://url_to_server', {headers: custom_header}); custom_header['MyHeader'] = 'Some header content';
Shouldn't it check for non-zero to add the custom header?