How to redirect from https://www.example.com to https://example.com in Deno Fresh?

284 views Asked by At

I have a website deployed on Deno deploy with a custom domain. I thought it would be possible to configure the appropriate redirects directly in the platform like I could do in for example, Vercel.

My question is: How can I configure redirects from https://www.example.com to https://example.com? Do I have to use middleware for this or is there another easier way that I'm missing?

1

There are 1 answers

0
mfulton26 On BEST ANSWER

The only way that I know of currently to do this with Deno Deploy is in your code.

Example from Redirect | Examples | Deno:

function handler(_req: Request) {
  return Response.redirect("https://example.com", 307);
}