Dinnerb0ne Debugging

const STREAMING = "";

addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
let newUrl = new URL(request.url);
let origin = request.headers.get("Origin");
newUrl.hostname = STREAMING;

const response = await fetch(newUrl, request);

const newResponse = new Response(response.body, response);
newResponse.headers.set("Access-Control-Allow-Origin", `*`);

return newResponse;
}
const STREAMING = "";

addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
let newUrl = new URL(request.url);
let origin = request.headers.get("Origin");
newUrl.hostname = STREAMING;

const response = await fetch(newUrl, request);

const newResponse = new Response(response.body, response);
newResponse.headers.set("Access-Control-Allow-Origin", `*`);

return newResponse;
}
14 Replies
Jacob
Jacob4y ago
What is happening when you try to request to the subdomain this route is on? Does it do anything?
MustafaJohn
MustafaJohnOP4y ago
Nope Let me reconfigure it, 2 minutes please.
Jacob
Jacob4y ago
If you replace this code with the following:
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
return new Response('hello')
}
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
return new Response('hello')
}
does it work? (just to make sure the route works)
Hello, I’m Allie!
@mustafajohn, Sub Sub domains are currently not supported for proxying on Non-Enterprise Plans.
Jacob
Jacob4y ago
TIL, thank you!!
MustafaJohn
MustafaJohnOP4y ago
Ah damn, that's unfortunate. Is there any particular reason as to why that is the case, I don't see any special overhead that's required for this.
Jacob
Jacob4y ago
I don't know, but some "seemingly trivial" features are locked behind Enterprise just because they either aren't that common, or I'd guess CF needs to get Enterprise customers somehow so less common things might get locked behind it
MustafaJohn
MustafaJohnOP4y ago
Bummer
Jacob
Jacob4y ago
Any reason you need the sub sub domain and can't do it on a single sub-domain?
MustafaJohn
MustafaJohnOP4y ago
Nope, just wanted to organize things further. Not a problem.
Jacob
Jacob4y ago
Gotcha! Yeah, I had the same issue in the past (before workers). Ended up just naming things a-b instead of a.b
MustafaJohn
MustafaJohnOP4y ago
Yup that is what I ended up doing.
Jacob
Jacob4y ago
Awesome! Good luck with your project 🙂
MustafaJohn
MustafaJohnOP4y ago
Thanks
Want results from more Discord servers?
Add your server