Workers Route URL Redirecting

Hey guys,

I have added a worker to my account and I have got everything set up and working on the browser side.

When I try and access my API via the provided workers URL it will work with CURL
However, if I try and use my subdomain it wont work unless I provide the -L parameter it will work.
This is because the -L flag allows URL redirects.

How can I set up my worker to respond to API calls without putting a redirect on the domain?
I have setup an A record to point to 192.0.2.1 in my DNS

image

I’m going to guess that what you’re seeing is an http to https redirect. Try hitting the https path directly.

2 Likes

Thanks, Robert!!!

I didn’t even think about trying https://

I have Always Use HTTPS enabled in my SSL settings. Is there a way to disable that for a single subdomain? So I can access my API with just HTTP?

That leaves those API calls unencrypted. I think it’d be much better to use HTTPS.

If you still really want to use unencrypted API calls, you’d have to disable Always Use HTTPS for the entire zone, then use Page Rules to enable it for just the main domain.

2 Likes

This is an API call, so you don’t need a redirect. Just configure the clients to use https://red.net/api rather than http://red.net/api. More and more features will be made HTTPS only by the major browsers in the future, adding to the list that currently includes HTTP/2, Brotli, AMP, payments, fullscreen, service workers etc.

2 Likes