How to integrate Netlify Functions with a React application using Next.js - Emmanuel Katto

Hi everyone, I am Emmanuel Katto from Uganda. I’m building a web application using Next.js and React, and I’m looking to integrate it with Netlify Functions. I’ve set up my project using the create-next-app command and have written some serverless functions using Netlify Functions. However, I’m having trouble figuring out how to integrate the two.

Specifically, I’m trying to use a Netlify Function to handle authentication and authorization for my Next.js app. I’ve created a function that checks for valid authentication credentials and returns a JSON response if they’re valid. However, I’m not sure how to call this function from my Next.js app.

I’ve tried using the next/headers API to send a request to the Netlify Function, but I’m getting a 405 Method Not Allowed error. I’ve also tried using Axios to make a GET request to the function URL, but that doesn’t seem to work either.

Can anyone provide guidance on how to properly integrate Netlify Functions with a Next.js application? Are there any specific configurations or settings that need to be set up in order to make this work?

Thanks!
Emmanuel Katto

Have you referenced our documentation on getting started with functions?