firebase-tools
firebase-tools copied to clipboard
Error 403 on next js redirect SSR
[REQUIRED] Environment info
firebase-tools: 12.6.1
Platform: Ubuntu
[REQUIRED] Test case
Hi, I'm using next 13 with pages directory and I'm trying to use a simple redirection from a page to another with server side rendering and I'm getting a 403 error
[REQUIRED] Steps to reproduce
Create a next js 13 app with pages directory:
-
npx create-next-app@latest What is your project named? my-app Would you like to use TypeScript? Yes Would you like to use ESLint? Yes Would you like to use Tailwind CSS? Yes Would you like to use src/ directory? No Would you like to use App Router? (recommended) No Would you like to customize the default import alias (@/)? Yes What import alias would you like configured? @/
-
Create a folder
exampleand a file index.tsx inside with the following:
export function getServerSideProps() {
return {
redirect: {
destination: "/",
permanent: false,
},
};
}
export default function Index() {
return <div>Example</div>;
}
- Deploy with firebase hosting https://firebase.google.com/docs/hosting/frameworks/nextjs?hl=es-419
- Enter your-domain.com/example` page in the browser
[REQUIRED] Expected behavior
Redirection works
[REQUIRED] Actual behavior
Redirection is getting a 403 error
The deployment creates any SSR code as a cloud function - I encountered this same issue and was able to work around it by updating my IAM settings for both Cloud Functions and Cloud Run in my Google Cloud Console.
https://cloud.google.com/functions/docs/securing/authenticating?&_ga=2.197954991.-1080258126.1678554131#authenticating_function_to_function_calls
https://cloud.google.com/run/docs/authenticating/public
Hope this helps.
Hey @lucasoz, as @kevineleven mentioned in the comment above, your Cloud Fuction(Next.js server) should be publicly accessible. It's public by default but your organization policy can change that.
Please confirm if allowing public access fixes the issue for you.
Hey @lucasoz. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@lucasoz if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.