Skip to content

Commit

Permalink
fix: better error messages for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Apr 30, 2023
1 parent 4611ad9 commit df10b10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
bearerToken: ${{ secrets.WESBITE_UPDATE_TOKEN }}
data: '{"fonts": true, "algolia": true, "download": true, "axisRegistry": true}'
retry: 1
retryDelay: 30000
retryWait: 15000
9 changes: 4 additions & 5 deletions website/app/routes/actions/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ export const loader: LoaderFunction = async () => {
export const action: ActionFunction = async ({ request }) => {
const data: UpdateData = await request.json();
const header = await request.headers.get('Authorization');
invariant(header, 'No authorization header was sent with the request');

invariant(data, 'No data was sent with the request');

if (header !== `Bearer ${process.env.UPDATE_TOKEN}`) {
if (!header || header !== `Bearer ${process.env.UPDATE_TOKEN}`) {
return new Response('Invalid update bearer token', { status: 401 });
}
if (!data) {
return new Response('Invalid update data', { status: 400 });
}

if (data.fonts) {
console.log('Updating fonts');
Expand Down

0 comments on commit df10b10

Please sign in to comment.