-
Notifications
You must be signed in to change notification settings - Fork 888
Create megastar #9421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create megastar #9421
Conversation
|
let url = new URL(request.url); | ||
url.hostname = "mburley.dreamvacations.com"; // Target domain | ||
let response = await fetch(url.toString(), request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When forwarding requests to another domain, you should create a new Request with updated headers rather than reusing the original request object. The current implementation might cause issues with headers like 'Host' that should match the target domain.
let url = new URL(request.url); | |
url.hostname = "mburley.dreamvacations.com"; // Target domain | |
let response = await fetch(url.toString(), request); | |
let url = new URL(request.url); | |
url.hostname = "mburley.dreamvacations.com"; // Target domain | |
let newRequest = new Request(url.toString(), { | |
method: request.method, | |
headers: request.headers, | |
body: request.body, | |
redirect: 'follow' | |
}); | |
let response = await fetch(newRequest); |
addEventListener("fetch", event => { | ||
event.respondWith(handleRequest(event.request)); | ||
}); | ||
|
||
async function handleRequest(request) { | ||
let url = new URL(request.url); | ||
url.hostname = "mburley.dreamvacations.com"; // Target domain | ||
let response = await fetch(url.toString(), request); | ||
return response; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file appears to be a personal Worker script that proxies to a specific domain (mburley.dreamvacations.com) rather than a generic template or example that would be appropriate for the workers-sdk repository. Could you clarify the purpose of adding this file?
@@ -0,0 +1,10 @@ | |||
addEventListener("fetch", event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is missing a file extension. If this is intended to be a JavaScript Worker script, it should have a .js
extension.
Fixes #[insert GH or internal issue link(s)].
Describe your change...