Creating a POST Request to an External API with Next.js

2 replies
Last updated: Sep 24, 2022
Hello there. I have successfully extended the built-in actions of my docs to create a POST request to an external API. I am wondering if there is any risk to this method? I am using Next.js and could redirect to one of my API routes and handle the POST to external API there.
I would recommend your suggestion as well, because this would mean the POST is made from a server and not from the browser. This means you can safely secure API keys on your lambda without having to bundle them in the Sanity client-side studio.
thank you for your input! I will do that πŸ™‚

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?