Next.js Discord

Discord Forum

Trying to grab keywords using TextRazor API in Nextjs

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Avatar
Brown bearOP
So I was trying to connect to the TextRazor API using Nextjs to grab keywords from a text string but it was returning a CORS error when running locally with yarn. I used the Nextjs docs to implement CORS solution but now it just returns a 404.

Here's the code: https://github.com/NeilMisra99/text-extract. How do I fix this. Please help

2 Replies

Avatar
fuma 💙 joulev
You no longer have the res parameter in route handlers, please read the [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers) docs to learn to use route handlers in App Router.
Access-Control-Allow-Methods should be a header added to your NextResponse, but normally you won’t need the headers since they live under the same domain.
Btw the docs has an example for enabling CORS