Skip to content

Conversation

@Ankit-Kum-ar
Copy link
Contributor

OAuth Integration (Google SSO)

Implemented Google OAuth using passport-google-oauth20. The frontend flow is fully working and Google authentication completes successfully. To make it work with the backend, the following changes were required and have been applied locally:

Backend Code Changes

To support Google OAuth on the backend, the following updates were made:

  1. CORS Configuration (app.js) -
    Enabled CORS for frontend communication by specifying the origin and allowing credentials:
	app.use(cors({
	  origin: 'http://localhost:3000',
	  credentials: true
	}));
  1. Updated Auth Route (app.js) -
    Changed the auth route prefix from /auth to /api/auth to align with the frontend API calls:
	// app.use('/auth', authRoutes);
	app.use('/api/auth', authRoutes);
  1. Dotenv Import (passport.config.js) -
    Ensured environment variables are loaded by importing and configuring dotenv:
import dotenv from 'dotenv';
dotenv.config();

After making these changes, test the complete OAuth flow from frontend to backend to ensure everything works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants