D
Deno

help

setting a cookie for import requests

Ccyzyvos9/22/2023
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. never mind, I solved it by routing the request through a deploy playground
DAHDeno AI Helper9/22/2023
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. 🦕
Ccyzyvos9/22/2023
not exactly what I was looking for but still good to know!

Looking for more? Join the community!