deploying Angular 6 Universal to GCP App Engine


deploying Angular 6 Universal to GCP App Engine



I'm looking for an example project that's using Angular 6 Universal and is successfully deploying to GCP App Engine. I've searched GitHub but can't find an example--the Universal Starter doesn't include deployment. Also, my old Angular 5 Universal config is not working for this new V6 project.



The current error is coming from nginx: "502 Bad Gateway"
It seems to be the favicon.ico file that's causing the problem--looks like a Node.js issue. I just dealt with this on a pure Node.js project (not Angular) and was able to resolve it, but I can't find the right config in the Angular context.



server.ts


app.use(favicon('src/favicon.ico'));



angular.json (start of it)


{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"appname": {
"root": "",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/browser",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
{
"glob": "favicon.ico",
"input": "src",
"output": "/"
},
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
}
],
"styles": [
{
"input": "node_modules/@angular/material/prebuilt-themes/indigo-pink.css"
},
"src/styles.css"
], ...



dispatch.yaml (because I have multiple services using the same domain)


dispatch:
# Default service serves the typical web resources and all static resources.
- url: "*/favicon.ico"
service: default





Looking at the nodejs docs samples for App Engine on Github, it looks like a "serve-favicon" package is being used. Are you using something like that? Also, in the interest of removing a layer of complexity, are you able to get this to work without Angular?
– Christopher P
Jul 3 at 10:29





Yes, I am using serve-favicon. I eventually found the issue (see answer). Thx for the comment.
– beachCode
6 hours ago




1 Answer
1



The issue was not properly starting Node in package.json. This one line in scripts fixed the problem...


"scripts": {
...
"start": "node dist/server.js",






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to add background colour in existing image using Swift?

Moria Casán

How to make file upload 'Required' in Contact Form 7?