So I want to debug my next.js app. Problem is a big part will not debug. So I added the chrome attached debugger (in launch.json):
{ "type": "pwa-chrome", "request": "launch", "name": "Launch Chrome against localhost", "url": "http://localhost:3010", "webRoot": "${workspaceFolder}" }
So the way I use this is I run in a terminal: "npm run dev" and then press F5 in vscode. This works partially as the react components & next.js pages will be debugged. The problem is the fetch calls with getStaticProps() will not.
So I looked in the docs of next.js and there it is written, use script like: "dev": "NODE_OPTIONS='--inspect' next dev" When I then run next in the terminal with: "npm run dev" I get a build error: the command "NODE_OPTIONS" is either written wrong or could not be found.
So how can I debugg these next.js functions like getStaticProps() ? Also should I write an issue-ticket to next.js?
Edit: It should also mention that the API is a asp.net core API, not a next.js API.
Edit 2: Well now I am bypassing this problem by using the SWR package.
getStaticProps
/getStatcPath
/getServerSideProps
all run on the server, as such any output from them will be available on the terminal you started the server on, not on the browser/debugger console.return: { props: { post, debugValue }}
and then log it inside the React component which receives that prop (might not cover all cases).