ppt-tool/frontend/next.config.mjs
Vadym Samoilenko f2f729a50b Switch Azure AD auth to MSAL SPA (browser-side token exchange)
- Replace server-side ConfidentialClientApplication + OAuth callback
  with MSAL browser popup flow (PKCE, no client_secret required)
- Backend: add POST /sso-token endpoint that validates Azure AD ID token
  via Microsoft JWKS, issues session cookie; remove /login + /callback
- Frontend: install @azure/msal-browser + @azure/msal-react, wrap app
  with MsalProvider, login page uses loginPopup() → sends id_token to backend
- Pass NEXT_PUBLIC_AZURE_* env vars through next.config.mjs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 12:34:52 +00:00

87 lines
2.1 KiB
JavaScript

const API_URL = process.env.API_INTERNAL_URL || 'http://localhost:8000';
const nextConfig = {
env: {
NEXT_PUBLIC_AZURE_TENANT_ID: process.env.AZURE_AD_TENANT_ID || '',
NEXT_PUBLIC_AZURE_CLIENT_ID: process.env.AZURE_AD_CLIENT_ID || '',
},
basePath: "/ppt-tool",
assetPrefix: "/ppt-tool",
publicRuntimeConfig: {
basePath: "/ppt-tool",
},
reactStrictMode: false,
distDir: ".next-build",
// Proxy API and static asset requests to FastAPI backend.
//
// The /api/v1/* rewrite uses a `missing` condition on the Accept header so
// it does NOT match SSE requests (EventSource always sends Accept: text/event-stream).
// SSE paths have explicit route handlers in app/api/v1/*/stream/[id]/route.ts
// that stream events properly. Normal JSON requests go through the rewrite as before.
async rewrites() {
return [
{
source: '/api/v1/:path*',
missing: [
{ type: 'header', key: 'accept', value: 'text/event-stream' },
],
destination: `${API_URL}/api/v1/:path*`,
},
{
source: '/app_data/:path*',
destination: `${API_URL}/app_data/:path*`,
},
{
source: '/static/:path*',
destination: `${API_URL}/static/:path*`,
},
];
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "pub-7c765f3726084c52bcd5d180d51f1255.r2.dev",
},
{
protocol: "https",
hostname: "pptgen-public.ap-south-1.amazonaws.com",
},
{
protocol: "https",
hostname: "pptgen-public.s3.ap-south-1.amazonaws.com",
},
{
protocol: "https",
hostname: "img.icons8.com",
},
{
protocol: "https",
hostname: "present-for-me.s3.amazonaws.com",
},
{
protocol: "https",
hostname: "yefhrkuqbjcblofdcpnr.supabase.co",
},
{
protocol: "https",
hostname: "images.unsplash.com",
},
{
protocol: "https",
hostname: "picsum.photos",
},
{
protocol: "https",
hostname: "unsplash.com",
},
],
},
};
export default nextConfig;