Redirects suddenly adding extra element to redirect path

Site name: utils.syncora.be / syncora-utils

Yesterday we tested one of our functionalities, a simple short linking service, and we noticed the redirects not working anymore.
Looking into the logs, I noticed that the path that is being requested was wrong:

Original url: https://url.syncora.be/greatescape/bwsadd

Redirect config:

[[redirects]]
  from = "https://url.syncora.be/*"
  to = "https://utils.syncora.be/url/:splat"
  status = 200
  force = true

Expected redirect: https://utils.syncora.be/url/greatescape/bwsadd
Actual redirect: https://utils.syncora.be/url/url/greatescape/bwsadd

→ Notice the second /url in the path.

I tried redeploying: same result
I removed the /url from my redirect config: would redirect without any url parth in the path, as expected
Re added the correct part → again double /url in path

So there seems to be something broken at the moment, with no way of fixing it.
I did work around it by also acceping the double /url/url path in my application for now, but this gives me very litle confidence in the stability of the platform…

@Plutus Can you provide a URL that demonstrates the issue?

When I visit https://url.syncora.be/greatescape/bwsadd I receive only a 301 directly to bookeo.com.

Is it https://utils.syncora.be/url/ that’s firing the 301?

Hi @nathanmartin ,

The fact that the url I gave in my original question redirects to bookeo.com is because of the workaround that I implemented. This is the intended behaviour.

For example, if I go back to my logs from yesterday from before I worked around the issue, I saw this entry when calling that url:

Feb 1, 11:17:20 PM: 9646a652 INFO [GET] /url/url/greatescape/bwsadd (SSR)

This should be url/greatescape/bwsadd given the rewrite I have configured.

Visiting the url also just gave a 404 not found error, because my next.js was not responding to those urls.

@Plutus I’d guessed the end result was likely due to the workaround.

Ignoring that, is the intended flow:
https://url.syncora.be/greatescape/bwsadd

https://utils.syncora.be/url/greatescape/bwsadd

https://bookeo.com/...

I’ve never seen a normal netlify redirect “add an extra piece of URL” like you’re describing here.

My own wild guesses would be:

  1. The URL was entered as https://url.syncora.be/url/greatescape/bwsadd which would result in https://utils.syncora.be/url/url/greatescape/bwsadd

OR

  1. There’s another redirect in effect somewhere, or something occuring within your next application, since you mention “logs” and point to an entry that mentions “SSR”.

OR

  1. Perhaps you’re right, perhaps there’s something wrong with the Netlify redirects and I’ve just never encountered it before. Having a URL that demonstrates the issue would help people determine if that’s the case.

Hi @nathanmartin ,

I’ve just gotten around to setting up am identical test to what I have for my URL redirection, without doing an actual redirection, nor implementing the fix I did for my initial question.

The test can be performed here:
https://test.syncora.be/a/b

This should return exactly the same as this route: https://utils.syncora.be/test/a/b
Given that I have the following redirect in place:

[[redirects]]
  from = "https://test.syncora.be/*"
  to = "https://utils.syncora.be/test/:splat"
  status = 200
  force = true

But it serves a 404 on the test.syncora.be url.

Looking at the logs, I get the following entry:
Feb 23, 11:33:04 AM: 7f88b054 INFO [GET] /test/test/a/b (SSR)

Which tells me the redirect is going to https://utils.syncora.be/test/test/a/b instead of what it is supposed to do.

This setup worked perfectly before my latest deploy of Februari 1st 2024, not sure what has changed in between that date and December 31st 2023 but this is when I first noticed the issue.

Logs can be found under the site utils.syncora.be

The code that handles this endpoint is very straightforward:

import { NextRequest, NextResponse } from "next/server";

type ShortLinkHandlerContext = {
  params: {
    tenantSlug: string;
    routeSlug: string;
  };
};

export async function GET(
  request: NextRequest,
  { params: { tenantSlug, routeSlug } }: ShortLinkHandlerContext,
) {
  // Do nothing, just return some data
  return NextResponse.json({
    tenantSlug,
    routeSlug,
  });
}

The only other thing in the repository that could influence the routing should be the next.js middleware, but this is not triggering for those routes:

import { NextRequest, NextResponse } from "next/server";
import { verifySecret, m2mHeader } from "@syncora/shared/server/m2m";

export default function middleware(req: NextRequest) {
  if (!verifySecret(req.headers.get(m2mHeader))) {
    return new NextResponse("Cannot access this endpoint", { status: 400 });
  }
  return NextResponse.next();
}

export const config = {
  // Match ALL api routes, except for the webhooks, they should be public
  matcher: "/api/((?!webhooks).*)",
};

There is not much more to the repository than this.

@Plutus I just created a “Drag & Drop” deployment consisting only of:

_redirects

/*  https://utils.syncora.be/test/:splat  200!

Visiting https://65d87c3e5f14bedba869f73d–extraordinary-kitten-412ccf.netlify.app receives a 308 status, pushing to a location of /test

Visiting the path /a/b does work:


Visiting your URL of https://test.syncora.be receives a 308 status, pushing to a location of /test/test

Visiting the path /a/b does not work - which will be because it’s going to /test/test/a/b as your logs indicate.