Conversation
|
@bajtos hindsight please |
| 'content-type': 'application/json', | ||
| accepts: 'application/json' | ||
| accepts: 'application/json', | ||
| authorization: 'Bearer Bz8B9c8hKIp+/IyePpgORexkDDq+8c9atapgGuudtQ0=' |
There was a problem hiding this comment.
I am not a fan of having this configuration deep in the source code. Can we move the value to a constant exported by lib/constants.js?
For example:
export const RPC_AUTH = 'Bearer Bz8B9c8hKIp+/IyePpgORexkDDq+8c9atapgGuudtQ0='| export const RPC_REQUEST = new Request('https://api.node.glif.io/', { | ||
| headers: { | ||
| authorization: 'Bearer Bz8B9c8hKIp+/IyePpgORexkDDq+8c9atapgGuudtQ0=' | ||
| } | ||
| }) |
There was a problem hiding this comment.
Thank you, @juliangruber, for testing this. I should have tested it myself to verify my assumptions. 🙈
My understanding was based on the following docs:
https://developer.mozilla.org/en-US/docs/Web/API/Request/Request
options Optional
An object containing any custom settings that you want to apply to the request. The possible options are:
(...)
I did a bit of testing in the Web Inspector console, and at least in Safari, the constructor call new Request(RPC_REQUEST, { headers: { /* more headers */ } }) does not merge the headers from RPC_REQUEST with the headers from the options. Instead, the headers from the options replace those from the original request.
| export const MAX_CAR_SIZE = 200 * 1024 * 1024 // 200 MB | ||
| export const APPROX_ROUND_LENGTH_IN_MS = 20 * 60_000 // 20 minutes | ||
|
|
||
| export const RPC_REQUEST = new Request('https://api.node.glif.io/', { |
There was a problem hiding this comment.
This should be RPC_URL now that it's just a URL string and not a request object.
We already use that same name in other places, e.g. here:
Would be nice to afterwards find out whether this is how
Requestworks, or maybe a Zinnia bug.