I have the following code:
"use server";
import { revalidatePath } from "next/cache";
import { z } from "zod";
import Airtable from 'airtable';
Airtable
.configure({
apiKey: 'PAT KEY'
})
Airtable
.base('ID');
export async function registerSignUp(prevState: { message: string; }, formData: FormData,) {
const schema = z.object({
email: z.string(),
});
const parse = schema.safeParse({
email: formData.get("email"),
});
if (!parse.success) {
return { message: "Failed to sign up" };
}
const data = parse.data;
try {
await Airtable.Table.create(data);
revalidatePath("/");
return { message: `Signed Up!` };
} catch (e) {
return { message: "Failed to sign up" };
}
}
So all of the above, obvs with the PAT key and ID added works locally but not on production.
I am using Vercel free tier to host my site and wonder if that is the problem. Or on airtable there is some CORS or domain whitelisting somewhere
update:
I have added a console log to the catch section for the error thrown and got this:
TypeError: Expected signal to be an instanceof AbortSignal
at new q (/var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:5:131465)
at /var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:5:132911
at new Promise (<anonymous>)
at Object.X [as default] (/var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:5:132863)
at Object.e [as default] (/var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:1:21616)
at e.runAction (/var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:1:10849)
at e._createRecords (/var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:1:24092)
at /var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:1:13135
at new Promise (<anonymous>)
at e.create (/var/task/dist/apps/fe/brochure/.next/server/chunks/838.js:1:13072)