1

After lots of development locally using ng serve to interact with my angular app, I decided to add firebase hosting. After completing the setup, I clicked on the web link, which never loaded. Using 'firebase emulators: start' in the terminal yielded a page blank page, but with a working title and background color. In the console, I found these 2 errors:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.Understand this errorAI

and

main-BG7YVEIX.js:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

The errors in question

Here is my build section of angular.json

"build": {
  "builder": "@angular-devkit/build-angular:application",
  "options": {
    "outputPath": "dist/goalApp",
    "index": "src/index.html",
    "browser": "src/main.ts",
    "baseHref": "/",
    "polyfills": [
      "zone.js"
    ],
    "tsConfig": "tsconfig.app.json",
    "assets": [
      "src/assets",
      {
        "glob": "**/*",
        "input": "public"
        
      }
    ],
    "styles": [
      "src/styles.css"
    ],
    "scripts": [],
    "server": "src/main.server.ts",
    "prerender": true,
    "ssr": {
      "entry": "server.ts"
    }
  },
  "configurations": {
    "production": {
      "budgets": [
        {
          "type": "initial",
          "maximumWarning": "1MB",
          "maximumError": "1.5MB"
        },
        {
          "type": "anyComponentStyle",
          "maximumWarning": "4.5kB",
          "maximumError": "5kB"
        }
      ],
      "outputHashing": "all"
    },
    "development": {
      "optimization": false,
      "extractLicenses": false,
      "sourceMap": true
    }
  },
  "defaultConfiguration": "production"
},

and my firebase.json

{
  "hosting": {
    "public": "dist/goalApp",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/browser/index.csr.html"
      }
    ]
  }
}

I looked through this thread. But none of the answers seem to work for me. Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Since my title is being rendered, I assume the build knows the base folder and the other errors are something else.

What do I need to change to get my app rendered?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.