This is a Next.js API proxy server project bootstrapped with create-next-app
.
- Clone this repository
git clone [email protected]:Crossmint/api-proxy-firebase.git
- Add your credentials
cp sample.env .env.local
Add your values to this file
CROSSMINT_API_URL=https://staging.crossmint.com/api
CROSSMINT_PROJECT_ID=
CROSSMINT_CLIENT_SECRET=
NEXT_PUBLIC_FIREBASE_API_KEY=
FIREBASE_CLIENT_ID=
FIREBASE_PRIVATE_KEY=
FIREBASE_CLIENT_EMAIL=
Guide to obtain firebase service credentials: https://firebase.google.com/docs/admin/setup
You'll need to generate a PEM Private Key from firebase settings -> service accounts -> generate new private key
- Start the dev server
npm run dev
# or
yarn dev
# or
pnpm dev
- Get a firebase token to test API out
Open http://localhost:3000 with your browser and click the "Sign in with Google" button and sign into a google account.
Copy the encoded JWT and pass this as a header with property name authorization
Test in postman: (kinda private link)
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out Next.js deployment documentation for more details.
Once deployed you will need to add an authorized domain to your firebase project if you want to use the test token generator. This can be found on the root page of the deployed app in a browser. For example, https://api-proxy-firebase.vercel.app/
. On this page you can click the "Sign in with Google" button to get a JWT for testing out the API. To add the authorized domain do the following:
- Go to the Firebase console for your project.
- In the left sidebar, click on the "Authentication" option.
- If you don't see it, expand the "Build" accordian
- Click on the "Settings" tab.
- Scroll down to the "Authorized domains" section and add your domain.
- Save the changes.