Disable https for specific api routes?

I have an API which a very old game is trying to send data to. This old application (circa 2004) cannot handle HTTPS. It must use HTTP. Is there a way to configure my wrangler.toml to specify specific routes for my Pages project to use HTTP instead of HTTPS?
65 Replies
Hello, I’m Allie!
You could have your Worker redirect based on the protocol?
Register
Register7mo ago
Hmmm. Im still a little bit new to the terminology. I thought I was using "Pages" and I thought "Workers" were something else? Or are "Pages" a super set of "Workers" in a way?
Register
Register7mo ago
@HardlyWorkin' I have also created a Page Rule (after reading some SO post) Do you think this is the right direction?
No description
Register
Register7mo ago
After I did this, I get this:
No description
Register
Register7mo ago
in my "Pages" project, I have this file: /functions/api/submit.ts
import EventContext from "@/EventContext";

export async function onRequestGet(ctx: EventContext) {
console.log("submit get");
return Response.json({result: "submit get"});
}

export async function onRequestPost(ctx: EventContext) {
console.log("submit post");
return Response.json({result: "submit post"});
}
import EventContext from "@/EventContext";

export async function onRequestGet(ctx: EventContext) {
console.log("submit get");
return Response.json({result: "submit get"});
}

export async function onRequestPost(ctx: EventContext) {
console.log("submit post");
return Response.json({result: "submit post"});
}
Register
Register7mo ago
Since I am working with Pages I assumed I'd use Page rules?
No description
Hello, I’m Allie!
No, Page Rules are something else, and are no longer recommended for use Pages and Workers are two separate products, but they do share some commonalities. You cannot configure your Pages Project with wrangler.toml for deployment
Register
Register7mo ago
Alright - are you suggesting I move my API logic from my Pages project and into its own "Worker"?
Hello, I’m Allie!
No, you can keep it in Pages. In fact, this shouldn't require any changes to configuration.
Register
Register7mo ago
Thanks! Still unclear on how to use HTTP though. Do I need to configure a worker rule? Confused about this because I am using Pages - so the naming is confusing me
Register
Register7mo ago
This is my project repo. I have my functions directory which contains my API and my site directory which is my static website which Pages automatically deploys for me when I push to my repo. (Lovely btw)
No description
Register
Register7mo ago
So from my perspective, I am using "Pages" and I have "Functions" inside my Pages project
Register
Register7mo ago
No description
Register
Register7mo ago
so what am I supposed to do to get this /api/submit route working with HTTP?
Hello, I’m Allie!
Do you only want it to apply to /api/submit, or to the entirety of /api?
Want results from more Discord servers?
Add your server