Netlify Dev Functions Locally troubleshooting

Hey @Dennis, thank you very much for your response.

Unfortunately, the workaround you propose didn’t solve the core problem.

However, I could further investigate the issue, and here is what I found out:

:pushpin: SETUP

I am have followed the steps in this tutorial (Solve CORS once and for all with Netlify Dev).

:mag_right: OBSERVATION 1)

When developing locally, functions server is listening to a port that is different than the port where the app is running. So the netlify functions cannot be called without triggering CORS issues.

Indeed, while functions server is listening on a given port…

*Note: the port number is not consistent, it changes everytime I run netlify dev

… the app runs on a different port

As a consequence, calling http://localhost:<functions_server_port>/.netlify/functions/node-fetch from http://localhost:3000/ triggers CORS errors.

:mag_right: OBSERVATION 2)

In production, calling /.netlify/functions/node-fetch works as expected.

As you can notice below, calling https://<my_domain>/.netlify/functions/node-fetch returns the expected result (see picture below).

As a result, we can infer that in production, the functions server listen on the same port as the port where the app is running.

The issue thus becomes the following:

:thinking: PROBLEM

How might we force functions server to listen on port 3000 in development?

I have investigated this issue (Netlify Dev Port command not working), and installed the lastest version netlify-cli@2.59.0.

However, running netlify dev -p 3000 still doesn’t have any effect: the functions server still listens to a different port.

Could someone help me figure that out please ?

Thanks