How to Handle Redirects In Glitch

I am trying to create a gatsby blog and calling Wordpress api similar to . Can i do a redirects from to non www website.

Struggling to Handle Redirects like we do in Wordpress Blogs.

There are a few ways you can do this:

Cloudflare DNS

You can set a redirect using Cloudflare. Learn more about that here.

NodeJS Express Redirect

Remix a node project, like this one, and add the following code to your index.js file:

const path = require("path");

const fastify = require("fastify")({
  logger: false,

fastify.get("/", function (request, reply) {

  { port: process.env.PORT, host: "" },
  function (err, address) {
    if (err) {
    console.log(`Your app is listening on ${address}`);`server listening on ${address}`);

(replacing “your_website_here” with your site’s url of course), then add the domain you want to redirect to the custom URL tab of the project.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.