5

Hi i am using the headless cms 'next-wordpress-starter ' for my blog and added a middleware to handle the traffic coming from "x" site to be redirected back to that site. on local environment it works perfect but when i deployed in vercel it shows this error : 500: INTERNAL_SERVER_ERROR Code: EDGE_FUNCTION_INVOCATION_FAILED

import { NextResponse } from 'next/server';

export function middleware(req) {
  let referrer_path1 = req.referrer;
  console.log(referrer_path1);
  if (referrer_path1.includes('x-domain')) {
    let redirect_url = `https://x-domain/${req.nextUrl.pathname}`;
    return NextResponse.redirect(redirect_url);
  }
  return NextResponse.next();
}

is the issue from vercel side or is there any other solution to this kind of routing ?

0 Answers0