fix: Add backend proxy for GLB files to resolve CORS in ImageTo3DModal
Build and Deploy / build-and-push (push) Successful in 27s

This commit is contained in:
AI Bot
2026-09-14 21:31:40 +05:30
parent 79d8d9b4fa
commit 90127e98c0
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -246,6 +246,22 @@ app.post('/api/users/deduct-credit', authenticate, async (req, res) => {
}
});
// 9.5 Proxy for downloading GLB files to fix CORS issues in frontend viewers
app.get('/api/proxy/glb', async (req, res) => {
const { url } = req.query;
if (!url) return res.status(400).json({ error: 'URL required' });
try {
const response = await axios.get(url, { responseType: 'stream' });
res.setHeader('Content-Type', 'model/gltf-binary');
// Add CORS headers for the frontend to easily fetch it
res.setHeader('Access-Control-Allow-Origin', '*');
response.data.pipe(res);
} catch (err) {
console.error('Proxy error:', err.message);
res.status(500).json({ error: 'Failed to proxy file' });
}
});
// 10. Upload file
app.post('/api/upload', authenticate, upload.single('file'), (req, res) => {
if (!req.file) return res.status(400).json({ error: 'No file uploaded' });