Some checks failed
Build and Push Docker Images / docker (push) Failing after 2m20s
BREAKING CHANGE: All environment variables are now runtime-configurable Changes: - Removed ALL build-time NEXT_PUBLIC_* variables from Dockerfile and CI/CD - Created server-side proxy routes for Wren API (/api/wren/*) - Refactored wrenClient.ts to use proxy endpoints (reduced from 400+ to 200 lines) - Updated checkoutClient.ts and emailClient.ts to remove NEXT_PUBLIC_ fallbacks - Hardcoded metadataBase in layout.tsx (no longer depends on env var) - Updated .env.local to use runtime-only variables (WREN_API_TOKEN, NocoDB config) Security improvements: - Wren API token never exposed to browser - All secrets stay server-side - No sensitive data baked into build Configuration: - Wren API: Set WREN_API_TOKEN in docker-compose or .env - NocoDB: Set NOCODB_* variables in docker-compose or .env - No Gitea secrets/variables needed for build (only registry credentials) Docker build is now truly environment-agnostic - same image works in any environment with different runtime configuration.
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
|
|
/**
|
|
* GET /api/wren/portfolios
|
|
* Proxy endpoint to fetch portfolios from Wren API
|
|
* This keeps the WREN_API_TOKEN secure on the server
|
|
*/
|
|
export async function GET() {
|
|
try {
|
|
const apiToken = process.env.WREN_API_TOKEN;
|
|
|
|
if (!apiToken) {
|
|
console.error('WREN_API_TOKEN is not configured');
|
|
return NextResponse.json(
|
|
{ error: 'Wren API is not configured' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
|
|
const response = await fetch('https://www.wren.co/api/portfolios', {
|
|
headers: {
|
|
'Authorization': `Bearer ${apiToken}`,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
const errorText = await response.text();
|
|
console.error('Wren API error:', response.status, errorText);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch portfolios from Wren' },
|
|
{ status: response.status }
|
|
);
|
|
}
|
|
|
|
const data = await response.json();
|
|
return NextResponse.json(data);
|
|
} catch (error) {
|
|
console.error('Error fetching Wren portfolios:', error);
|
|
return NextResponse.json(
|
|
{ error: error instanceof Error ? error.message : 'Failed to fetch portfolios' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|