blob: e8b535e75f2442106f7908ff2224dd942cd230e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import axios from 'axios';
export default async function handler(req, res) {
const { url = '', page = 1, limit = 30 } = req.query;
let offset = (page - 1) * limit;
const params = [
`q.op=AND`,
`q=keywords_s:"${url}"`,
`indent=true`,
`rows=${limit}`,
`start=${offset}`,
];
try {
// let result = await axios(
// process.env.SOLR_HOST + `/solr/searchkey/select?` + params.join('&')
// );
let result = await axios.post(
process.env.SOLR_HOST + `/solr/searchkey/select`,
params.join('&'),
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
);
console.log(result.data);
res.status(200).json(result.data);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
}
|