I installed Adafruit's WiFiNINA library as described in the docs. When I use the WiFININA > WiFiWebClient sketch and try to just do a plain GET request just to test my endpoint's URL, I get a 301 response that points to the HTTPS URL for the endpoint. When I try to use the WiFiSSLClient sketch to connect instead, the sketch just hangs until eventually timing out and moving on.
After doing some reading, it sounds like I need to upload the SSL certificate for Netlify to the board somehow, but I spent a couple hours trying to do that this morning and got super lost. I can't upload the FirmwareUpdater sketch from the custom Adafruit library because of some build errors (missing SerialNina, NINA_GPIO0, NINA_RESETN). That led me to this thread where the author tried using WiFiNINA_Generic, so I tried that. After following the complex installation instructions, I tried uploading the FirmwareUpdater board and it "bricked" my M4. Luckily double-tapping the board's reset button made it so I could upload a different sketch to undo that. Eventually I got rid of that WiFiNINA_Generic library and reverted back to the Adafruit WiFiNINA library and replicated each of the original issues to verify it was working OK.
Am I correct that I need to install an SSL cert on the board to access my Netlify endpoint? If so, how exactly would I do that with the Metro M4 and Airlift shield? If not, what might be going on here and how can I troubleshoot?
Note: the hostname of the endpoint in all the samples below has been changed to my-app.netlify.app just for safety. I have verified with Postman that it is working as expected.
Relevant code from the WiFiWebClient sketch:
Code: Select all
Serial.println("\nStarting connection to server...");
if (client.connect("my-app.netlify.app", 80)) {
client.println("GET /api/swipe HTTP/1.1");
client.println("Host: my-app.netlify.app");
client.println("Connection: close");
client.println();
}
Code: Select all
Starting connection to server...
HTTP/1.1 301 Moved Permanently
Location: https://my-app.netlify.app/api/swipe
Server: Netlify
X-Nf-Request-Id: 01GMR89XZS2NXFC33PQVTH6T0K
Date: Tue, 20 Dec 2022 17:11:38 GMT
Content-Length: 65
Content-Type: text/plain; charset=utf-8
Code: Select all
Serial.println("\nStarting connection to server...");
if (client.connect("my-app.netlify.app", 443)) {
client.println("GET /api/swipe HTTP/1.1");
client.println("Host: my-app.netlify.app");
client.println("Connection: close");
client.println();
}
Code: Select all
Starting connection to server...