Firebase hosting not working for angular app

Discussão em 'Angular' iniciado por DrakeCub, Dezembro 11, 2024.

  1. DrakeCub

    DrakeCub Guest

    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.
    ​

    [​IMG]

    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?

    Continue reading...

Compartilhe esta Página