#Export config deprecated, what to replace it with?
1 messages · Page 1 of 1 (latest)
Hi @abstract siren. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The export const config syntax is indeed deprecated in Next.js. However, the replacement depends on the specific configuration you are trying to set.
For instance, if you are trying to set the bodyParser to false, you would need to use the onRequest function in your route handler to consume the request body as a stream or with raw-body. Here's an example:
import { IncomingMessage, ServerResponse } from 'http'
import { json } from 'micro'
export async function onRequest(req: IncomingMessage, res: ServerResponse) {
const body = await json(req)
// your code here
}
Unfortunately, the knowledge sources provided do not include a direct replacement for the export const config syntax. I would recommend checking the Next.js documentation (https://nextjs.org/docs) for more information on how to handle specific configurations in the latest versions of Next.js.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@abstract siren kapa.ai is still learning and improving, please let us know how it did by reacting below
This is the handler:
export async function POST(req: NextRequest) {
const buf = await req.text();
const sig = req.headers.get("stripe-signature");
let event: Stripe.Event;
console.log("🔏 -> Verifying webhook signature")
try {
if (!sig) return;
event = stripe.webhooks.constructEvent(buf, sig, webhookSecret);
} catch (err) {
...
What do I need to replace here?
@calm steppe
Let me check the knowledge base for you. One moment! :books:
Based on the provided code and the knowledge sources, it seems like you don't need to replace anything in your handler function. The export const config syntax that was deprecated doesn't appear in your handler function.
Your function is correctly using the NextRequest object to get the request body and headers. As long as stripe.webhooks.constructEvent and webhookSecret are properly defined and imported, your function should work as expected.