@mintlify/previewing 4.0.1035 → 4.0.1037
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,8 +19,33 @@ export const run = async (argv) => {
|
|
|
19
19
|
const io = new SocketServer(server);
|
|
20
20
|
const requestHandler = await setupNext();
|
|
21
21
|
const localIp = getLocalNetworkIp();
|
|
22
|
+
const apiUrl = argv.apiUrl ?? process.env.MINTLIFY_API_URL ?? 'http://localhost:5000';
|
|
23
|
+
const accessToken = argv.accessToken;
|
|
24
|
+
const subdomain = argv.subdomain;
|
|
25
|
+
process.env.MINTLIFY_CLI_ACCESS_TOKEN = accessToken ?? '';
|
|
26
|
+
process.env.MINTLIFY_API_URL = apiUrl;
|
|
27
|
+
if (subdomain)
|
|
28
|
+
process.env.MINTLIFY_CLI_SUBDOMAIN = subdomain;
|
|
22
29
|
// next-server is bugged, public files added after starting aren't served
|
|
23
30
|
app.use('/', express.static(NEXT_PUBLIC_PATH));
|
|
31
|
+
app.post('/_mintlify/api-public/search/:subdomain', express.json(), async (req, res) => {
|
|
32
|
+
const targetSubdomain = subdomain ?? req.params.subdomain;
|
|
33
|
+
try {
|
|
34
|
+
const upstream = await fetch(`${apiUrl}/api/cli/${targetSubdomain}/search`, {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: {
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
|
|
39
|
+
},
|
|
40
|
+
body: JSON.stringify(req.body),
|
|
41
|
+
});
|
|
42
|
+
const data = await upstream.json();
|
|
43
|
+
res.status(upstream.status).json(data);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
res.status(502).json({ error: 'search proxy failed' });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
24
49
|
app.all('*', (req, res) => requestHandler(req, res));
|
|
25
50
|
const onChange = () => {
|
|
26
51
|
io.emit('reload');
|