Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Open `/src/index.js` and delete the existing code and paste in the following exa
const originalAPIHostname = "api.mysite.com";

export default {
async fetch(request) {
async fetch(request, env) {
// Change just the host. If the request comes in on example.com/api/name, the new URL is api.mysite.com/api/name
const url = new URL(request.url);
url.hostname = originalAPIHostname;
Expand All @@ -191,8 +191,8 @@ export default {
// since once a Request has been constructed, its URL is immutable.
const newRequest = new Request(url.toString(), request);

newRequest.headers.set("cf-access-client-id", CF_ACCESS_CLIENT_ID);
newRequest.headers.set("cf-access-client-secret", CF_ACCESS_CLIENT_SECRET);
newRequest.headers.set("cf-access-client-id", env.CF_ACCESS_CLIENT_ID);
newRequest.headers.set("cf-access-client-secret", env.CF_ACCESS_CLIENT_SECRET);
try {
const response = await fetch(newRequest);

Expand Down