29 Replies
is that
wrangler.toml
? If so, pages doesn't use that.That'll be Workers Sites
Oh! That's an R2 bucket?
Not R2
Duh! I was thinking i was in the pages channel.
i have that
already
// serve static files from assets/static directory
app.get('/static/*', serveStatic({ root: '/' }))
so the fules serve fine
its just fetching those inside another route
to load them in edge
A Worker cannot fetch itself or another Worker that is on the same zone over a HTTPS URL
You would need to use service bindings for the two Workers to communicate
yah but the two workers cant share the same domain right?
Can they ?
They can do that as well
Bind the two workers together with this: https://developers.cloudflare.com/workers/configuration/bindings/about-service-bindings/
Then you can run
example.com/worker1/*
and example.com/worker2/*
or whatever routes you need. And when a Worker needs to fetch the other Worker, do not use the public URL through direct fetch, do it through the service binding insteadahhh i see
so i gotta rewrite my whole script then
Ideally you just need to swap out
fetch
for bindingName.fetch
Shouldnt be an entire rewritei need to make a whol enew worker then
Why?
u said i need two workers now
one to fetch the other
I thought you already had two workers. Could you provide more details about the current setup then?
A Worker is fetching itself, right?
yea i got one worker only
I would have expected Hono would have a built-in function to fetch its own static assets but I don't think so
On that note, more of a workaround than a solution but you can actually service bind a worker to itself
how?
i might just re-do this whole thing.. im trying to make an ad-servee that can serve html ads and image ads
storing assets in the [site] static was my approach but ig iuess now its biting me a bit
Normally you wouldn't have issues with it, it's just what appears to be Hono's implementation
If you rely heavily on assets I would recommend at least looking into Pages
where
<BINDING_NAME>
is what you call the binding as it appears in env
and service
is the workers own nameso what do i do
in wrangler
Put the above in
wrangler.toml
which bart
part
if its the same worker?
i can still jut use one worker?
i see
so i can use one worker?
So that should work ?
or dont put the full path
in the adWorker.fetch ?
Keep the full domain and path in it
hmm
assuming
adWorker
is available that will work but it will most likely be c.env.adWorker
instead for honoWait, it kinda worked
but the images dont load
example
see here: https://alveoplatform.com/static/g/index.html
but if <script src="https://alveoplatform.com/adServe/fzCZ3GQW"></script>
When i put the adtag in
see the difference?
So its serving the html but paths getting messed up, we're getting close lol
TY both btw, so close lo
I think i need to use direct absolute paths in the oriignak HTML file