I have a simple react site that is going to send a request to Square. The React portion of the form submits CC data, etc… but needs a server side bit of code in Go to then submit to the Square API. I am trying to get a Go function working locally, as well as deployed on netlify.
First, I have my GO configured per the instructions. However, when including a .toml file, it caused my netlify build to NOT build the site… basically overrode the site settings via Dashboard. Makes sense, except nothing I found in documentation indicated how you build both the react/nodejs site AND the go functions. That combo seems to not be documented well with regards to how you get netlify to build both without the Go .toml config causing the nodejs react bits to not build/deploy.
In the .toml, there is the command = “make build”. So what I tried was adding the Makefile and adding in the npm run build step, which I think is what is needed. This builds the Go function AND the nodejs, and it does deploy. I also see for my site it says one lambda function deployed, and the log shows invoked. Though the response I get back is a 429 Too many requests via sentry.io. I am not sure why this is, or how to solve this one.
The bigger issue, besides better documentation around deploying a go function AND a nodejs site together, is how to run the Go function locally. There is info on doing this for nodejs, but nothing on how you run the Go lambda locally so that you can test the site making a call to the local Go function.
So, how do we do this? Is the Go function a standalone server, and I just execute it after I build it via the ./goFunction?? When I do run it like this, it seems to just sit there… so not sure if it is actually running like a server. If so, I am not entirely sure how to access it. In my React site, I use the /.netlify/functions/goFunc in a link or button or in my case, the Square form handler code then invokes the /.netlify/functions/goFunc using the fetch() library call.
It would be ideal if there was a tutorial on how you create a react site that makes a call to a Go function and how to do test it locally then see it deploy to the site.
Any info on anyone who has gotten this to work would be fantastic.
Thank you.