Re:What I Learned from Making the Python Back End for My New...
by daft_pink on Wednesday October 16, 2024 @04:57PM
(#41863789)
So essentially, you only let the server side rendering function, access the API and don’t secure it at all beyond that?
You could essentially use a static JWT token that only that nexts cloud function knows?
Re:What I Learned from Making the Python Back End for My New...
by eigenvalue on Wednesday October 16, 2024 @05:27PM
(#41864010)
Yeah, I restrict it by the IP address, so the FastAPI backend can only receive connections from localhost or the one machine running the NextJS app. There are certainly lots of ways you could restrict it, such as using a password or key.
And the user auth stuff in NextJS is incredibly easy using the standard Next-Auth flow: https://next-auth.js.org/
You basically just set up a new application in the Google Cloud console, enable the Google Plus API for the app, and create the OAuth keys, and that's about it. Just add the secret key and identifier to your .env file for the NextJS app and it "just works".