I want to force https connections for my React app deployed on Google App Engine node.js flexible environment. My React app was created with
npx create-react-app my-cool-app And I have an app.yaml placed in project root directory. The app.yaml contains the following:
env: flex runtime: nodejs service: frontend-staging I have seen other questions/answers on here mention using the npm helmet library. But I don't understand how that applies to my case. Isn't Google App Engine serving a static build directory using nginx? There is no Express server here - just front end code. How can I set http security headers using this library if I just have front end code? Do I need to place an Express app server in between nginx and my React stuff?
Also I asked Google Support about modifying the nginx.conf file. But, according to them, I would have to SSH into the instance and modify the file that way. Well, what happens if the load on an instance increases and GAE automatically fires up another instance? Now I have to somehow detect that and manually SSH into that instance to fix the nginx.conf file? I saw that mentioned as a potential solution on here as well but this seems like a poor option.
Note: I don't think this is a duplicate. I am specifically asking how to implement the helmet library with nginx + Express + React + code examples for GAE node.js flex environment, not a higher level strategy question.