Update server.js
Browse files
server.js
CHANGED
@@ -61,14 +61,16 @@ app.get('/q', (req, res) => {
|
|
61 |
const filemoonUrl = req.query.q;
|
62 |
|
63 |
if (!filemoonUrl || !filemoonUrl.startsWith('https://filemoon.')) {
|
64 |
-
return res.status(400).
|
65 |
}
|
66 |
|
67 |
// Generate a random 16-character hex path
|
68 |
const randomPath = crypto.randomBytes(8).toString('hex');
|
69 |
|
70 |
urlMap.set(randomPath, filemoonUrl);
|
71 |
-
|
|
|
|
|
72 |
});
|
73 |
|
74 |
// Dynamic route to serve the embedded Filemoon player
|
|
|
61 |
const filemoonUrl = req.query.q;
|
62 |
|
63 |
if (!filemoonUrl || !filemoonUrl.startsWith('https://filemoon.')) {
|
64 |
+
return res.status(400).json({ error: 'Invalid or missing Filemoon URL.' });
|
65 |
}
|
66 |
|
67 |
// Generate a random 16-character hex path
|
68 |
const randomPath = crypto.randomBytes(8).toString('hex');
|
69 |
|
70 |
urlMap.set(randomPath, filemoonUrl);
|
71 |
+
const fullUrl = `${req.protocol}://${req.get('host')}/vid/${randomPath}`;
|
72 |
+
|
73 |
+
res.json({ url: fullUrl });
|
74 |
});
|
75 |
|
76 |
// Dynamic route to serve the embedded Filemoon player
|