Skip to content

Commit

Permalink
chore: copy commits from older branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jipperism committed Oct 30, 2023
1 parent 0e8d690 commit 74d06ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cors-proxy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export default {
const apiUrl = url.searchParams.get(QUERYSTRING_KEY);

if (apiUrl == null) {
return new Response(`Missing GET parameter: ${QUERYSTRING_KEY}`);
return new Response(`Missing GET parameter: ${QUERYSTRING_KEY}`, {
status: 400,
statusText: `Bad Request: ${QUERYSTRING_KEY} param undefined`,
});
}

// Rewrite request to point to API URL. This also makes the request mutable
Expand Down
20 changes: 20 additions & 0 deletions frontend/components/hypercert-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ export function HypercertCreateForm(props: HypercertCreateFormProps) {
}

const image = await exportAsImage(IMAGE_SELECTOR);

if (!image) {
setSubmitting(false);
return;
}

const metaData = formatValuesToMetaData(
values,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down Expand Up @@ -511,7 +517,21 @@ const exportAsImage = async (id: string) => {
//useCORS: true,
proxy: "https://cors-proxy.hypercerts.workers.dev/",
imageTimeout: 0,
}).catch((e) => {
toast("Error loading hypercert image . Please contact the team.", {
type: "error",
});
console.error("Error exporting image: ", e);
return undefined;
});

if (!canvas) {
toast("Error loading hypercert image . Please contact the team.", {
type: "error",
});
return undefined;
}

const image = canvas.toDataURL("image/png", 1.0);
return image;
};

0 comments on commit 74d06ab

Please sign in to comment.