Angular project doesn't work under CNAME on CloudFlare Pages

Discussão em 'Angular' iniciado por wlinator, Dezembro 4, 2024.

  1. wlinator

    wlinator Guest

    I have deployed my Angular project with Cloudflare Pages, and it works perfectly fine under fritfest.pages.dev, I created a CNAME record in CloudFlare to this pages domain:

    [​IMG]

    However, when I go to this fritfest.com, it doesn't properly open the page, instead I get the following error in the browser console:

    Loading module from “https://<domain>.com/polyfills-FFHMD2TL.js” was blocked because of a disallowed MIME type (“text/html”).
    fritfest.com
    Loading failed for the module with source “https://fritfest.com/polyfills-FFHMD2TL.js”. fritfest.com:18:72
    Error: NG0908
    H https://fritfest.com/main-7CTPKIN2.js:3
    t https://fritfest.com/main-7CTPKIN2.js:7
    ngZoneFactory https://fritfest.com/main-7CTPKIN2.js:7
    i https://fritfest.com/main-7CTPKIN2.js:7
    hydrate https://fritfest.com/main-7CTPKIN2.js:7
    get https://fritfest.com/main-7CTPKIN2.js:7
    xS https://fritfest.com/main-7CTPKIN2.js:7
    ov https://fritfest.com/main-7CTPKIN2.js:7
    Uv https://fritfest.com/main-7CTPKIN2.js:8


    I'm confused as to why this is happening. The angular.json file is as following:

    {
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
    "fritfest": {
    "projectType": "application",
    "schematics": {},
    "root": "",
    "sourceRoot": "src",
    "prefix": "app",
    "architect": {
    "build": {
    "builder": "@angular-devkit/build-angular:application",
    "options": {
    "outputPath": "dist/fritfest",
    "index": "src/index.html",
    "browser": "src/main.ts",
    "polyfills": [
    "zone.js"
    ],
    "tsConfig": "tsconfig.app.json",
    "assets": [
    {
    "glob": "**/*",
    "input": "public"
    }
    ],
    "styles": [
    "src/styles.css"
    ],
    "scripts": []
    },
    "configurations": {
    "production": {
    "budgets": [
    {
    "type": "initial",
    "maximumWarning": "500kB",
    "maximumError": "1MB"
    },
    {
    "type": "anyComponentStyle",
    "maximumWarning": "2kB",
    "maximumError": "4kB"
    }
    ],
    "outputHashing": "all",
    "baseHref": "/",
    "deployUrl": "https://fritfest.com/"
    },
    "development": {
    "optimization": false,
    "extractLicenses": false,
    "sourceMap": true,
    "fileReplacements": [
    {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.development.ts"
    }
    ],
    "baseHref": "/"
    }
    },
    "defaultConfiguration": "production"
    },
    "serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "configurations": {
    "production": {
    "buildTarget": "fritfest:build:production"
    },
    "development": {
    "buildTarget": "fritfest:build:development"
    }
    },
    "defaultConfiguration": "development"
    },
    "extract-i18n": {
    "builder": "@angular-devkit/build-angular:extract-i18n"
    },
    "test": {
    "builder": "@angular-devkit/build-angular:karma",
    "options": {
    "polyfills": [
    "zone.js",
    "zone.js/testing"
    ],
    "tsConfig": "tsconfig.spec.json",
    "assets": [
    {
    "glob": "**/*",
    "input": "public"
    }
    ],
    "styles": [
    "src/styles.css"
    ],
    "scripts": []
    }
    }
    }
    }
    },
    "cli": {
    "analytics": false
    }
    }


    wranger.toml:

    name = "fritfest"
    pages_build_output_dir = "dist/fritfest/browser"

    [vars]
    NODE_VERSION = "18.19.1"

    Continue reading...

Compartilhe esta Página