I am making a web app with node.js using google app engine.
I want to redirect https://MY_PROJECT_ID.appspot.com to mycustome domain. I followed this maual but does not work. What is problem?
https://cloud.google.com/appengine/docs/flexible/nodejs/how-requests-are-routed#routing_with_a_dispatch_file
dispatch.yaml
dispatch:
- url: 'fermi.me/' //my custom domain
service: default
console
gcloud app deploy dispatch.yaml
Configurations to update:
descriptor: [./nodejs-getting-started/2-structured-data/dispatch.yaml]
type: [routing rules]
target project: [XXXXXXX]
Do you want to continue (Y/n)? Y
Updating config [dispatch]...done.
Even though, dispatch.yaml is successfully deployed, if I executed 'app deploy', Redirection does not work. I already registered domain in Google cloud, and static websites worked.
I found the fundamental problem and it solved.
I already connected to static website with bucket.
https://cloud.google.com/storage/docs/hosting-static-website
There is a error in web-console in App-Engine domains setting.(Message: "Domain is already mapped to a project in google cloud platform". There is a critical error in this maunal.
https://cloud.google.com/appengine/docs/standard/python/mapping-custom-domains
The sample error message. It only appears when you already connect storage static website to domains.
error : domain is already mapped to a project in google cloud platform
You can use command-line tool with gcloud beta. Webconsole makes error but commandline works. After you mapped domain, you can now use webconsole. You should add cnames as the maunal above(mapping domains) explains There is a guide.
https://stackoverflow.com/a/46780534/9049333
The dispatch file is only used to direct a request already reaching your app to the appropriate service/module. If the request doesn't match any dispatch.yaml rules it is automatically directed to the default service (making your rule redundant, BTW).
The dispatch file does NOT redirect a request to another domain (or anywhere back outside your app, really). So you're on the wrong track at this point.
You need to take care of such redirection in your application. Possibly relevant starting points for that:
Disable default domain https://[project-id].appspot.com of Node JS on Google App Engine
HTTP to HTTPS redirection on App Engine
Related
Update
I have found, that the configuration is "correct", in that the application gateway properly routes to the correct backend when using the "/payment" path. On the app in question however, the path is still "/payment" which obviously does not work. I know I can circumvent this by using Override Backend Path to "/", but then, as said, the app does not load any CSS / JS files because it looks on the root of the host (I think)
I have a setup going with Azure Application Gateway for a project I am working on currently.
Setup
The basic setup goes like this:
Public IP --> Appliction Gateway --> Private Endpoints --> WebApps.
I have enabled multi-site hosting, have given an Azure domain (.cloudapp.azure.com) and have enabled path based routing.
So for example mydomain.germanywestcentral.cloudapp.azure.com/payment will route to a certain backend.
Issue
The issue is, while the HTML is loading just fine, all the CSS/JS is not looking at
"mydomain.germanywestcentral.cloudapp.azure.com/payment/site/style.css"
but at
"mydomain.germanywestcentral.cloudapp.azure.com/site/style.css"
I already googled for hours how to solve this issue but to no avail. I realize Azuer is one of the lesser used clouds as of now, but hopefully someone here can, at least in concept, explain what is happening and what needs to be done. Any pointers are helpful here :)
Disclaimer
I am rather new to the whole networking topic and Azure, so I am not sure how to solve this issue. How do I tell the app to not look at the root, but at the /payment. If I go to "mydomain.germanywestcentral.cloudapp.azure.com/site/style.css" it loads the file just fine.
Note
One thing: In order for any of this to work, I had to set "Override Backend Path" to "/", which is probably what is causing the issue.
However, if I turn this off, it does not load anything, and instead fails loading the site altogether.
Images of the settings
HTTP Setting for Payment Backend
Listener Configuration
Rule Configuration
I am trying to setup one parent domain (app.mydomain.com) for front for 2 web apps in the backend.
mail.mydomain.com and module.mydomain.com. I have implement path based routing. I need to routing to work so
app.mydomain.com/* points module1.mydomain.com
app.mydomain.com/module2/* points module2.mydomain.com/
Routing seems to work, however when browsing module2, it css and js are not loaded and the site doesnt work. accessing module2 directly works normally.
Have you routing rules to change your URL?
Since you are using App Gateway, the URL that your backend is seeing is (app.mydomain.com) instead of module2.mydomain.com.
So, maybe when you’re using the AppGateway, your backend is looking for a CSS into the wrong path…
I have a nodejs application as the frontend and built my api in apsnetcore webapi. I'd like to run the api in the same domain i.e. /api. However I'm presented with runtime environment question when creating app service where I have to choose between dotnetcore and node. Anyone know how to get this to work?
Looks like you can from the link here if you
"tweak URL Rewrite rules in web.config so that specific URLs are being handled by IISNode and the other ones by ASP.NET."
I have existing app that runs on Heroku. It's a simple web app with no background jobs or database.
Basically it has three endpoints. One of them serves the HTML, the other is POST endpoint for communicating with backend and third is GET endpoint that renders error HTML content as well.
Now the frontend is not single page application and the goal is not to be one. It's just HTML page with a form and some links. The front end can be used without Javascript.
My questions are:
Can I re-use existing ExpressJS code? I was thinking about importing route callbacks and use them inside the "functions".
I know there is Firebase hosting that can serve static content. However, as I mentioned the server can respond with HTML content so I'd need traditional routing (such as /error url for rendering HTML error). In my ExpressJS app I use .ejs templating so I'd like to load the template and render it.
Can Firebase be set up so the "backend" (functions) can be placed on my own domain? I'd like to call relative URLs from my index file (like that POST endpoint) instead of using Google Firebase URL.
I'm really just trying to find out if my use case can fit the Firebase infrastructure. I think it's a good candidate since I need the web app to respond infrequently and it's not really demanding, not many people would use it. This is also my hobby project so I'm trying to minimize costs.
To answer your questions:
Yes you can, but keep in mind some things are limited. In my case, I had tried to use multer library for multipart forms but didn't work and had to resort to using busboy instead. To use an Express app for a function endpoint, you simply just pass your app as the onRequest function parameter like so: functions.https.onRequest(app).
Docs:
https://firebase.google.com/docs/functions/http-events#using_existing_express_apps
The hosting is for static files only. You can't use that with .ejs. Unless, you're thinking to use that as a proxy to your Express app..
Yes, you can set custom domains so you can use your domain(s) instead of default ones. Reference: https://firebase.google.com/docs/hosting/custom-domain
From your project's Hosting page, enter the wizard for connecting a custom domain:
If you have only one Hosting site, click Connect domain.
If you have more than one Hosting site, click View for the desired site, then click Connect domain.
Enter the custom domain name that you'd like to connect to your Hosting site.
(Optional) Check the box to redirect all requests on the custom domain
to a second specified domain (such that yourdomain.com and
www.yourdomain.com redirect to the same content).
Click Continue to initiate the validation process.
I deployed sample node.js application on GAE.
From admin console, under version i can see my 'version-project-id.appspot.com' url and able to access it also.
This is the only version which is deployed and serving.
However when I access 'project-id.appspot.com' url, I get 404 error.
Doesn't project-id.appspot.com url automatically points to latest and promoted version-project-id.appspot.com url?
Is there any other setting to do to make this work?
Make sure you go to:
https://console.cloud.google.com/appengine/versions?project={project-id}&moduleId=default
and set the default to the version you want.
Right now your service is not set as default. For that just change service in your app.yaml file to be default. It will start serving that service on project-id.appspot.com
The design of server-side should be:
default service: controller for other services
- service 1
- service 2
Finally deleted that particular project and created a new one, re-deployed app in it. It worked as expected.