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.
Fix the issue https://github.com/vercel/ai-chatbot/issues/300
Default![20240404173719_rec_](https://github.com/vercel/ai-chatbot/assets/5254737/e2b6c932-6aa0-4260-b526-67cfbf0e5d93)
Response.redirect
after login is a 302 redirect. And it will blocklogout
andClear history
operation right after loginAfter changing to 307 redirect, this is working correctly now, and we can logout successfully.![image](https://github.com/vercel/ai-chatbot/assets/5254737/256380e8-8bc4-4964-acf3-11bf55e236f8)
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