Fix Mixed Content issue on staging (HTTPS/HTTP mismatch)
- Add Next.js API rewrites to proxy /api and /uploads requests - Update docker-compose.staging.yml to use relative API paths - Set NEXT_PUBLIC_API_URL to empty for staging (use rewrites) - Add BACKEND_URL env var for Next.js server-side proxying - Update all files to use relative paths when API_URL is empty This fixes the issue where the staging site (HTTPS) was trying to load resources from HTTP backend, causing Mixed Content errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,10 +28,34 @@ const nextConfig = {
|
||||
hostname: '192.168.0.202',
|
||||
pathname: '/uploads/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'staging.autonetsellcar.com',
|
||||
pathname: '/uploads/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'autonetsellcar.com',
|
||||
pathname: '/uploads/**',
|
||||
},
|
||||
],
|
||||
},
|
||||
env: {
|
||||
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL || 'http://192.168.0.202:8000',
|
||||
// Don't override empty string - it means use relative paths with rewrites
|
||||
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
|
||||
},
|
||||
async rewrites() {
|
||||
const backendUrl = process.env.BACKEND_URL || 'http://localhost:8000';
|
||||
return [
|
||||
{
|
||||
source: '/api/:path*',
|
||||
destination: `${backendUrl}/api/:path*`,
|
||||
},
|
||||
{
|
||||
source: '/uploads/:path*',
|
||||
destination: `${backendUrl}/uploads/:path*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user