Don't worry about overthinking this. You're new to this tech stack and you're already rocking it!
If your site is gonna remain static I suggest to not complicate things. You can use a third party provider like Sendgrid or set up an email sending function in a serverless way.
This allows you to host your site in Vercel's Now, Netlify, Github pages, etc (most of them have really easy integrations with serverless functions) and you can declare environment variables without any hassle.
I hope I haven't deviated much regarding what you already made but this would avoid setting up a server just to send emails.
Let me know if that suits you!
Thanks for the reply!
I did look into GitHub Pages and similar solutions. I have used SendGrid and other transactional email APIs in the past.
Part of it was I actually wanted the learning experience of setting up / administering my own server on a Digital Ocean droplet, and I figured I'd do my learning on my own site rather than a client's. I've been using Linux full-time for awhile now, and my ultimate goal is to be somewhat of a full-stack developer. (I also have a few unrelated Bash / Python scripts that I am currently running on the same machine)
Since it's already up and running and most of the work is behind me, I would ideally like to just run the email script locally on my VPS rather than adding in another 3rd party service. I've done this before with PHP, but with PHP (assuming best practices are followed) I never had the worry of my server-side script being served to the browser.
So assuming I'm going to do this the hard way, what would you recommend? Set up a separate simple Express API? Or is there a way to communicate with the back end in the same Create React App app (without exposing any credentials)?
Somehow in my mind I thought you have a Next project (that's why I was so thoughtful about the static part of it). If you're using create-react-app you can make a mini Express server that only sends the email. CRA can read environment variables by default (create-react-app.dev/docs/adding-c...)
Thanks again, I'll look into that!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.