Currently utilizing:
export const getStaticProps = async () => {
export const getStaticPaths = async () => {
and accessing my API (pages/api/projects/) created with Next.js on my local host
const res = await fetch("http://localhost:3000/api/projects");
When deploying the app on Netlify, I encounter an error - connect ECONNREFUSED 127.0.0.1:3000 Attempting to change the URL to "/api/projects/"
const res = await fetch("/api/projects/");
results in a new error "TypeError: Failed to parse URL from /api/project" indicating that Next.js requires a complete URL to access the data.
The final URL on Netlify is , implying that the API needs to be up and running first. How can I achieve this if deploying the app is required to run the API?
"Netlify expects:"
const res = await fetch("https://v2ds.netlify.app/api/projects/");
But how do I access the API without building the application for the first time? Working with getStaticProps, getStaticPaths, Mongoose, and the Next.js API.
The primary question remaining is how to deploy my app on Netlify while still being able to access the data during build time?
Thank you, Appreciate any assistance.