Reverse proxy doesnt work

For Workers & Pages, what is the name of the domain?

What is the error number?

For some reason the worker is not triggering

What is the error message?

if we test the worker url it works but if we use domain url it goes to the website link which is not correct

What is the issue or error you’re encountering

Worker is not triggering as it should be

What are the steps to reproduce the issue?

If you go to this site

novopsych-api.defyn-digital.workers.dev/statistics

it works fine but if you go to

novopsych.com/api/statistics

This is the code im using

addEventListener(“fetch”, event => {
let request = event.request.clone();
let url = new URL(request.url);
url.hostname = ‘api.novopsych.com’;
if (url.pathname.startsWith(‘/api/’)) {
url.pathname = url.pathname.replace(‘/api’, ‘’);
}
event.respondWith(fetch(url, request));
});

This topic was automatically closed after 15 days. New replies are no longer allowed.