Request.url returns a weird host

I may be missing something simple but when I deploy a basic Next.js app and add a route like this:

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

export const dynamic = 'force-dynamic';

export async function GET(req: NextRequest) {
  return new NextResponse(req.nextUrl.origin, { status: 200 });  

On Netlify it doesn’t return the expected host name but rather this:


I suspect this is the host of the serverless function handling the route, but this doesn’t happen neither on localhost nor on Vercel. Is there some configuration setting or something I can set to fix this?

I’ve created this simple test project with create-next-app and it’s a nextjs 14 app. Could this be the cause? Or am I just missing something simple?


@ailon It doesn’t answer your direction question of “how you can change the behavior”, but to provide some additional information, I’d imagine that the [some-random-id] you’re referring to is actually the deploy ID, see:

Thanks, @nathanmartin. The “what that thing is” is not that important here, but why is the code returning some internal plumbing stuff URL rather than what it is expected to return - the user-facing URL of the request?

I understand that this could be due to the internal deployment architecture on Netlify (my ignorance is also a possibility :sweat_smile:) but there must be some way to work around it.

I understand it’s not important to you solving your issue, I just figured it’d provide additional context to what might be going on.

Knowing that Netlify deployments are atomic to various deploy id’s it might just be how they do things, but I’m as ignorant as you are to the inner workings, so it’d be up to Netlify to confirm if it’s correct and/or if there are workarounds.

I can’t reproduce this, I get the correct URL:

Hmm… I guess I’ll have to investigate what is happening on my end and provide you with a simple repro if it still doesn’t work. Thanks.