Repository navigation
Closed
Description
Is there an option to allow using an IP instead of a full domain when using fetch()?
Edit: I found the option, but I cannot get it to work.
Config:
using Workerd = import "/workerd/workerd.capnp";
# A constant of type `Workerd.Config` will be recognized as the top-level configuration.
const config :Workerd.Config = (
services = [
# The site worker contains JavaScript logic to serve static files from a directory. The logic
# includes things like setting the right content-type (based on file name), defaulting to
# `index.html`, and so on.
(name = "site-worker", worker = .siteWorker),
# Underneath the site worker we have a second service which provides direct access to files on
# disk. We only configure site-worker to be able to access this (via a binding, below), so it
# won't be served publicly as-is. (Note that disk access is read-only by default, but there is
# a `writable` option which enables PUT requests.)
(name = "site-files", disk = "content-dir"),
# Fetch
# (name = "internal-network", external = ( address = "127.0.0.1:7379" ) ), # First try
(name = "internal-network", network = ( allow = ["public", "private"], ) ), # Second try
#KV
(name = "kv", disk = ( path = "kv", writable = true, allowDotfiles = false ) )
],
# We export it via HTTP on port 8080.
sockets = [ ( name = "http", address = "*:8080", http = (), service = "site-worker" ) ],
);
# For legibility we define the Worker's config as a separate constant.
const siteWorker :Workerd.Worker = (
# All Workers must declare a compatibility date, which ensures that if `workerd` is updated to
# a newer version with breaking changes, it will emulate the API as it existed on this date, so
# the Worker won't break.
compatibilityDate = "2022-09-16",
# This worker is modules-based.
modules = [
(name = "hello.js", esModule = embed "hello.js"),
],
bindings = [
# Give this worker permission to request files on disk, via the "site-files" service we
# defined earlier.
( name = "files", service = "site-files"),
# Fetch
( name ="internalNetwork", service = "internal-network" ),
# KV
( name = "KV", kvNamespace = ( name = "kv" ) ),
# This worker supports some configuration options via a JSON binding. Here we set the option
# so that we hide the `.html` extension from URLs. (See the code for all config options.)
(name = "config", json = "{\"hideHtmlExtension\": true}")
],
);This is how I call the fetch function in the code: env.internalNetwork.fetch("http://127.0.0.1:7379/endpoint")
Initially, I used the ExternalServer option. I then tried using the Network option. Neither worked.
Reacted by Digital Grey Hat
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Allow "fetch" to use IP address[/-][+]Allow "fetch" to use IP address instead of a domain[/+]OnurGvnc commentedon Oct 12, 2022
I didn't test it. Can you try it like this
env.API.fetch("http://api/endpoint")kentonv commentedon Oct 13, 2022
Sounds like you may have been hitting the bug described in #62?
fix(server): facet channel UaF after alarm timeout
fix(server): facet channel UaF after alarm timeout