Use SSL with Dart and Managed VM's - google-app-engine

I wish to know how I can use a secure connection (https) with Dart and Managed VM's on localhost and when it's deployed.
Thank you.

When an application is deployed using gcloud preview app deploy the default is that the App Engine application will be served on both HTTP and HTTPS. If you have an application on
http://project.appspot.com
you can access it using HTTPS on
https://project.appspot.com
If not accessing the default version the URL are:
http://version.project.appspot.com
and HTTPS on
https://version-dot-project.appspot.com
Note the first . changing to -dot-.
You can specify the following int the app.yaml to only serve the application over HTTPS:
- url: /.*
script: dummy
secure: always
This will also redirect from HTTP to HTTPS, but unfortunately not do the rewrite from . to -dot- if not using the default version.
For local development using gcloud preview app run it is not possible to use HTTPS. The following quote is from the App Engine documentation:
The development web server does not support HTTPS connections. It
ignores the secure parameter, so paths intended for use with HTTPS can
be tested using regular HTTP connections to the development web
server.
See https://github.com/dart-lang/appengine/issues/16 and https://cloud.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Secure_URLs.

Related

React Github page not working as expected

I have create created a react app for ticket management and for connect with backend i have defined proxy in package.json as shown in the figure. this is finely working in local host. when i publish to github page, it not able to connect to backend and get 404 error since the proxy in package.json is not considering now. So how i define a proxy as like in the packag.json to github page i have hosted
github ripo: https://github.com/pranavmappoli/supportdesk
hosted page: https://pranavmappoli.github.io/supportdesk/
backend URL: https://pranavhelpdesk.herokuapp.com/
how could i resolve this issue other than putting the path in .env file
The webpack proxy is designed to be used as a hack during development.
In production you are supposed to configure CORS on the API or deploy the app to the same origin as it so you don't need a proxy.
An an alternative (not one I'd recommend) you could build a production ready proxy. If you do that then it will need to support CORS and cannot be hosted on Github pages which only support statics files.

How to force HTTPS with create-react-app on heroku

I'm running a very basic react app on Heroku and would like to force https on the production server, while still running localhost on https. I cannot for the life of me figure out how to do this on Heroku.
SSL and domain has been setup and works fine when I manually enter https:// before the domain. But if I manually type http:// this also works.
How do I redirect all http traffic to https for my react app on Heroko. I would like this to happen:
localhost:3000 still works in development
https is forced on production domain
create-react-app still runs without being "ejected"
Typically I'd set this up on the DNS, but Heroku only allows for a CNAME setup, so I cannot do this on the DNS level. I assume a custom server is required like express, but I cannot find any documentation on how to do this for production while stille working normally in development/localhost.

Google App Engine - Hosting project and website on same server

I have a NodeJs App Engine project . I also have an Apache website in another server which hosts the project dashboard. This site is the one using the node API.
I am willing to host both projects on the same server on this Google Cloud project.
Can this be achieved simply by using services in the app.yaml?
I also have an Apache website in another server which hosts the project dashboard.
What does this other server actually do? If it's serving static files, you could easily do this by adding a static_dir handler in your app.yaml
handlers:
# All URLs beginning with /dashboard are treated as paths to
# static files in the web-dashboard/ directory.
- url: /dashboard
static_dir: web-dashboard
If there is actual webserver code running, you could set up and app engine flex with a custom runtime & dockerfile to run apache
https://cloud.google.com/appengine/docs/flexible/custom-runtimes/
But an easier lift would be just rewriting your webserver code to work with one of app engines existing flex runtimes https://cloud.google.com/appengine/docs/flexible/
Once you do that, then you route traffic between the 2 services with dispatch.yaml
https://cloud.google.com/appengine/docs/standard/python/reference/dispatch-yaml

Webpack and React authorization 302 redirect on fetch

I am using Keycloak authorization server with React hosted via ASP.NET and Webpack. When I do a build and host through ASP.NET I have no problems with getting authorized methods on the host. When I deploy the whole project on the server there are also no problems with React connecting to the host. But when I am trying to do localhost development with Webpack proxy to my remote server, than I recieve 302 redirection to Keycloak login page. I log into the deployed app before the fetch, but it looks like the proxy is not recognized as the same browser. I have the 'credentials':'include' statement in my fetch init.
The problem was with Kestrel-Keycloak and http/https security. It appears that when you use a proxy like Nginx, Kestrel doesn't copy the headers. The problem can by solved by using:
app.UseForwardedHeaders
in Startup class, Configure method.

Connection between two custom App Engines

How do I connect between two App Engines?
I want to run a custom runtime with nginx for serving my frontend files and an other App Engine serving the backend with nodejs.
In my "one server setup" i use nginx to proxy everything from /api/ to localhost:3000 (my node instance)
I think i could start the Backend, look up the internal ip and proyx to that but i'd guess thats not the right way and it wouldn't allow me to test locally with gcloud app run.

Resources