Fix Meta OAuth 404 by adding missing @Get decorators and update redirects

This commit is contained in:
Hamza-Ayed
2026-03-30 18:12:51 +03:00
parent c890937181
commit 0c8a53f85e

View File

@@ -18,6 +18,8 @@ export class AuthController {
private readonly googleAdsService: GoogleAdsService, private readonly googleAdsService: GoogleAdsService,
) {} ) {}
@Get('meta')
@ApiOperation({ summary: 'Redirect to Meta Login | التوجيه لتسجيل الدخول بميتا' })
async loginToMeta(@Query('userId') userId: string, @Res() res: Response) { async loginToMeta(@Query('userId') userId: string, @Res() res: Response) {
const appId = this.configService.get<string>('meta.appId'); const appId = this.configService.get<string>('meta.appId');
const redirectUri = this.configService.get<string>('meta.redirectUri'); const redirectUri = this.configService.get<string>('meta.redirectUri');
@@ -26,6 +28,8 @@ export class AuthController {
return res.redirect(url); return res.redirect(url);
} }
@Get('meta/callback')
@ApiOperation({ summary: 'Meta OAuth Callback | استقبال كود ميتا' })
async metaCallback(@Query('code') code: string, @Query('state') state: string, @Res() res: Response) { async metaCallback(@Query('code') code: string, @Query('state') state: string, @Res() res: Response) {
if (!code) return res.status(HttpStatus.BAD_REQUEST).json({ message: 'No code provided' }); if (!code) return res.status(HttpStatus.BAD_REQUEST).json({ message: 'No code provided' });
try { try {
@@ -46,11 +50,11 @@ export class AuthController {
} }
// Redirect back to dashboard with success // Redirect back to dashboard with success
const frontendUrl = 'http://localhost:5001'; // Should be dynamic in prod const frontendUrl = '/frontend';
return res.redirect(`${frontendUrl}?auth=success&platform=meta`); return res.redirect(`${frontendUrl}?auth=success&platform=meta`);
} catch (error) { } catch (error) {
this.logger.error('Meta Auth failed:', error.message); this.logger.error('Meta Auth failed:', error.message);
return res.redirect('http://localhost:5001?auth=failed'); return res.redirect('/frontend?auth=failed');
} }
} }