vercel / ai-chatbot

A full-featured, hackable Next.js AI chatbot built by Vercel
https://chat.vercel.ai
Other
5.53k stars 1.63k forks source link

fix: few ui actions not working right after login #301

Closed gchust closed 1 month ago

gchust commented 3 months ago

Fix the issue https://github.com/vercel/ai-chatbot/issues/300

Default Response.redirect after login is a 302 redirect. And it will block logout and Clear history operation right after login 20240404173719_rec_

After changing to 307 redirect, this is working correctly now, and we can logout successfully. image

Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302 and

https://nextjs.org/docs/pages/api-reference/next-config-js/redirects#header-cookie-and-query-matching

Why does Next.js use 307 and 308? Traditionally a 302 was used for a temporary redirect, and a 301 for a permanent redirect, but many browsers changed the request method of the redirect to GET, regardless of the original method. For example, if the browser made a request to POST /v1/users which returned status code 302 with location /v2/users, the subsequent request might be GET /v2/users instead of the expected POST /v2/users. Next.js uses the 307 temporary redirect, and 308 permanent redirect status codes to explicitly preserve the request method used.

vercel[bot] commented 3 months ago

@gchust is attempting to deploy a commit to the Uncurated Tests Team on Vercel.

A member of the Team first needs to authorize it.