'Error only shows the first time using Axios on getInitialProps
Hi everyone i've an issue fetching data with Axios
Let me explain to you what im doing: i've my FrontEnd made in NextJs but my BackEnd was made on C# then when i try to fetch data in getInitialProps with axios
The error shows only the first time when i load the page shows:
My Network
But when i refresh the page all works fine
I'm aware that i can't fetch data using localhost without enable CORS
I´ve been looking a lot and found that i've to enabled on my custom server
UPDATE:
I used this for OPTION methods
Because i found in the network tab this error
But still not working, maybe i'm missing something or some configuration
If you need more information please let me know
MY SOLUTION
I've found the solution, i used getServerSideProps instead of getInitialProps and it works
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|