cyzyvos
cyzyvos10mo ago

setting a cookie for import requests

is there a way to modify request headers or set cookies for the GET requests that deno makes when resolving imports? concrete use case: I want to test a library that is served by a local static file server on my machine and forwarded through vs code's tunnel feature – but without a specific cookie, the tunnel serves a safety warning instead of the forwarded content.
3 Replies
cyzyvos
cyzyvos10mo ago
never mind, I solved it by routing the request through a deploy playground
Deno AI Helper
Deno AI Helper10mo ago
Based on the documentation, Deno does not provide a built-in way to modify request headers or set cookies for the GET requests it makes when resolving imports. However, Deno does support the use of environment variables to set authentication tokens for fetching modules from private repositories or servers that require authentication. This is done using the DENO_AUTH_TOKENS environment variable. In your case, if your local static file server supports authentication via bearer tokens, you could potentially use this feature to bypass the safety warning. You would need to set the DENO_AUTH_TOKENS environment variable to include the authentication token and the hostname of your local server. Here's an example of how you might set the DENO_AUTH_TOKENS environment variable:
DENO_AUTH_TOKENS=a1b2c3d4e5f6@localhost:8000
DENO_AUTH_TOKENS=a1b2c3d4e5f6@localhost:8000
In this example, a1b2c3d4e5f6 is the authentication token and localhost:8000 is the hostname of the local server. Please note that this information is not explicitly stated in the documentation and might not work for your specific use case. It's always a good idea to refer to the documentation for the most accurate and up-to-date information. 🦕
cyzyvos
cyzyvos10mo ago
not exactly what I was looking for but still good to know!