1

I have a ASP.NET Core 5 web API app which works fine and can get and post data with Postman, but when I am trying to access it with my Next.js app I get 500 failed, reason: unable to verify the first certificate. When I try to get fake data from https://jsonplaceholder.typicode.com/users it works without any problem. Do I need especial permission on IIS express? I'm new to this. Here is my code for Next.js:

const myHeaders = new Headers();
myHeaders.append("Content-Type","application/json");

const requestOptions = {
    method: 'GET',
    headers: myHeaders,
    body: raw,
    redirect:'follow'
};

var raw = JSON.stringify({
    "title": "titanic",
    "releaseDate": "1998-10-05",
    "genre": "romance",
    "price": 11.99
})

export const getStaticProps = async () => {
    const res = await fetch(`https://localhost:44310/api/movies`)
    const data = await res.json()

    return {
        props: {movies:data}
    }
}


const Movies = ({movies}) => {
    return ( 
        <div>
            <h1>movies</h1>
            {movies.map(m => (
                <div key={m.id}>
                    <a>
                        <h4>{m.title}</h4>
                    </a>
                </div>    
            ))}
         
        </div>
     );
}
 
export default Movies;
juliomalves
  • 42,130
  • 20
  • 150
  • 146
vahid
  • 23
  • 5
  • Does this answer your question? [Error: unable to verify the first certificate in nodejs](https://stackoverflow.com/questions/31673587/error-unable-to-verify-the-first-certificate-in-nodejs) – juliomalves Oct 10 '21 at 11:40
  • no not really it's not node.js. – vahid Oct 10 '21 at 16:09
  • The `fetch` request is being made from `getStaticProps` which runs on the server, in a Node.js environment. – juliomalves Oct 10 '21 at 16:25
  • 1
    i have a feeling it's to dp with iis express or my backend which is asp.net core webapi does not allow my front-end to access it – vahid Oct 10 '21 at 21:03

0 Answers0