Next.js Discord

Discord Forum

Changing redirect status from 307 to 308 for http to https redirect

Unanswered
Morelet’s Crocodile posted this in #help-forum
Open in Discord
Morelet’s CrocodileOP
Hi all, I'm managing a website using Next app router and vercel deployment and the SEO guy is asking the redirect from http://website.com to https://website.com to have a status of 308.
Currently, without any configuration, the redirect that vercel use has a 307 status.
I've also confirmed this with some of my other project that also use Next and Vercel, they automatically redirect to a https domain with 307 status.
With this in mind, I assume the change can't be made in the code since the request wouldn't make it pass vercel.
Is there any settings on the vercel dashboard for this case. If this post comes of empty I might make a discussion on the vercel repo.
Thanks in advance

8 Replies

heya might I ask you what redirect you're using? NextResponse.redirect() or redirect("..") from next/navigation on a server component?
seems to be pretty straightforward on NextResponse.redirect()
as far as I know.. the redirect function that is run on the server component doesn't actually change the status code, which is odd that you got a 307 when doing a redirect
since the html is streamed right away, the component that runs the redirect might have not been called before the status code is already sent by the server
oh i just found a function that does it
ig doing
import { permanentRedirect } from "next/navigation";

export function Page() {
  if (...) {
    permanentRedirect("/");
  }
}

should work
@iyxan23 as far as I know.. the `redirect` function that is run on the server component doesn't actually change the status code, which is odd that you got a 307 when doing a redirect
*a bit of correction on my part: it does this when you're doing it on a streaming context, like wrapping your async server component on a suspense element, sorry for that!