Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: #1714 migrate to axios.get #1819

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/server/api/routers/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TRPCError } from '@trpc/server';
import { AxiosError } from 'axios';
import axios, { AxiosError } from 'axios';
import Consola from 'consola';
import { z } from 'zod';
import { isStatusOk } from '~/components/Dashboard/Tiles/Apps/AppPing';
import { getConfig } from '~/tools/config/getConfig';
import { AppType } from '~/types/app';

import { createTRPCRouter, publicProcedure } from '../trpc';
import * as https from 'https';

export const appRouter = createTRPCRouter({
ping: publicProcedure
Expand All @@ -29,14 +30,21 @@
});
}

const res = await fetch(app.url, {
const agent = new https.Agent({
rejectUnauthorized: false,
Dismissed Show dismissed Hide dismissed
requestCert: false
});

return await axios.get(app.url, {
method: 'GET',
cache: 'force-cache',
headers: {
// Cache for 5 minutes
'Cache-Control': 'max-age=300',
'Content-Type': 'application/json',
'Cache-Control': 'max-age=300'
},
httpAgent: agent,
httpsAgent: agent,
timeout: 12 * 1000, // 12 seconds,
maxRedirects: 3
})
.then((response) => ({
status: response.status,
Expand Down Expand Up @@ -70,6 +78,5 @@
message: `Unexpected response: ${error.message}`,
});
});
return res;
}),
});
Loading