This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
The app uses NextAuth.js with Google OAuth for authentication.
NEXTAUTH_URL: Base URL of your application (e.g.,http://localhost:3000orhttps://buildcanada.com/bills)NEXTAUTH_SECRET: Secret key for signing JWT tokensGOOGLE_CLIENT_ID: Your Google OAuth client IDGOOGLE_CLIENT_SECRET: Your Google OAuth client secretMONGO_URI: MongoDB connection stringNEXT_PUBLIC_APP_URL: Public URL of your application (optional, for metadata)
If you get a JSON parsing error when navigating to the sign-in page:
-
Check environment variables:
- Create a
.env.localfile in the project root - Set the required variables (see list above)
- Run
node test-env.jsto verify they're set correctly
- Create a
-
Check the debug endpoint: Visit
http://localhost:3000/api/auth/debugto see which variables are detected -
Verify the NextAuth route: Visit
http://localhost:3000/api/auth/sessiondirectly to see if it returns JSON -
Check browser console: Look for any client-side errors
-
Ensure NEXTAUTH_URL is correct: This should be your full base URL (e.g.,
http://localhost:3000for development)
After setting up your environment variables, run:
node test-env.js
npm run devThen visit http://localhost:3000 and click the "Sign In" button. You should see a loading spinner briefly, then either the sign-in button or your user info.
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Create OAuth 2.0 credentials
- Add these URLs to your OAuth consent screen:
- Authorized JavaScript Origins:
https://buildcanada.com - Authorized Redirect URIs:
https://buildcanada.com/bills/api/auth/callback/google
- Authorized JavaScript Origins:
- Users can sign in with Google accounts
- New users are automatically created in the database
- Admin approval is required for new users (controlled by
allowedfield in User model) - Session management with automatic database sync