Skip to content

how to fetch from a local http server? #1523

Answered by kentonv
panva asked this question in Q&A
Discussion options

You must be logged in to vote

By default, Workers are only allowed to fetch from the public internet. This is to protect against SSRF attacks, where an application that tries to fetch user-provided URLs could be tricked by an attacker into fetching internal URLs that the attacker isn't supposed to be able to access. Since only public URLs can be fetched, such an attack is not possible by default.

There are two ways you can give your worker access to internal servers. I'll show examples below, but remember the full config format is documented in workerd.capnp.

Preferred approach: Define a service binding of type ExternalServer.

using Workerd = import "/workerd/workerd.capnp";

const config :Workerd.Config = (
  service…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@panva
Comment options

Answer selected by panva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants