Help

Re: Airtable integration with next does not work in production but works locally

474 0
cancel
Showing results for 
Search instead for 
Did you mean: 
tanil-lb
4 - Data Explorer
4 - Data Explorer

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)

3 Replies 3
Stephen378Baker
4 - Data Explorer
4 - Data Explorer

Hello,
Check the versions of the packages that you are using, such as airtable, next, and zod. Make sure that they are the same in your local and production environments, and that they are compatible with each other. You can use the package.json file to specify the exact versions of the packages that you want to use, and run npm install to install them. DogLikesBest
Best Regards

Horizon_App
4 - Data Explorer
4 - Data Explorer

Did you manage to solve it? Im getting the same exact error

sgtwompwomp
4 - Data Explorer
4 - Data Explorer

https://github.com/vercel/next.js/issues/55682

Hi, this solved my issue. Set experimental.serverMinification to false in next.config.js. Cheers!