update
This commit is contained in:
@@ -204,6 +204,31 @@ app.get('/api/ollama/config', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/search', async (req, res) => {
|
||||
try {
|
||||
const { q, limit, category } = req.query;
|
||||
const response = await axios.get(`${API_URL}/api/search`, {
|
||||
params: { q, limit, category }
|
||||
});
|
||||
res.json(response.data);
|
||||
} catch (error) {
|
||||
if (error.response) {
|
||||
// The request was made and the server responded with a status code
|
||||
// that falls out of the range of 2xx
|
||||
console.error('Search API Error:', error.response.status, error.response.data);
|
||||
res.status(error.response.status).json(error.response.data);
|
||||
} else if (error.request) {
|
||||
// The request was made but no response was received
|
||||
console.error('Search API No Response:', error.request);
|
||||
res.status(502).json({ error: 'Search service unavailable (timeout/connection)' });
|
||||
} else {
|
||||
// Something happened in setting up the request that triggered an Error
|
||||
console.error('Search API Request Error:', error.message);
|
||||
res.status(500).json({ error: 'Internal proxy error' });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Frontend server running on http://localhost:${PORT}`);
|
||||
console.log(`Admin dashboard: http://localhost:${PORT}/admin.html`);
|
||||
|
||||
Reference in New Issue
Block a user