Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

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.

Sep 24, 2022, 1:37 AM

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.

Sep 24, 2022, 10:48 AM

thank you for your input! I will do that 🙂

Sep 24, 2022, 4:25 PM Get the most out of your content is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.