简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM