Skip to content

Commit

Permalink
Merge pull request #179 from DNDACADEMY/develop
Browse files Browse the repository at this point in the history
fix: revalidate web fetch의 url이 잘못 들어가있어 에러가 나는 이슈 수정 (#178)
  • Loading branch information
saseungmin authored Aug 24, 2024
2 parents 9b782af + 5c46af7 commit 572a010
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions apps/admin/src/app/api/handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { api, type FetchError } from '@dnd-academy/core';
import { paramsSerializer } from '@dnd-academy/core';
import { put } from '@vercel/blob';
import { JWT } from 'google-auth-library';
import { GoogleSpreadsheet } from 'google-spreadsheet';
Expand Down Expand Up @@ -41,21 +41,19 @@ export const updateCurrentApplicantCount = async () => {

export async function revalidateWebPath(paths: string | string[]) {
try {
const response = await api<{
revalidated: boolean; message?: string; now?: number;
}, { secret: string; paths: string | string[]; }>({
const response = await fetch(`${process.env.WEB_ORIGIN}/api/revalidate?${paramsSerializer({
paths,
secret: process.env.REVALIDATION_TOKEN,
})}`, {
method: 'GET',
url: `${process.env.WEB_ORIGIN}/api/revalidate`,
params: {
secret: process.env.REVALIDATION_TOKEN,
paths,
},
});

return response;
} catch (error) {
const errorResponse = error as FetchError;
const data = await response.json() as {
revalidated: boolean; message?: string; now?: number;
};

return { revalidated: false, message: 'Error revalidating', status: errorResponse.response?.status || 500 };
return data;
} catch (error) {
return { revalidated: false, message: 'Error revalidating', status: 500 };
}
}

0 comments on commit 572a010

Please sign in to comment.