Why does transformer.js throw an error with Angular on Firebase?

Discussão em 'Angular' iniciado por Ero Stefano, Dezembro 8, 2024.

  1. Ero Stefano

    Ero Stefano Guest

    Today I added transformer.js on my Angular web app. Locally it works fine but the app deployed on Firebase throws an error.

    dialog-agent.component.ts:39 ERROR SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at hub.js:581:17
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (asyncToGenerator.js:3:1)
    at _next (asyncToGenerator.js:17:1)
    at _ZoneDelegate.invoke (zone.js:369:28)
    at Object.onInvoke (core.mjs:7251:33)
    at _ZoneDelegate.invoke (zone.js:368:34)
    at ZoneImpl.run (zone.js:111:43)
    at zone.js:2538:40


    It fails to get model json:

    /**
    * Fetches a JSON file from a given path and file name.
    *
    * @param {string} modelPath The path to the directory containing the file.
    * @param {string} fileName The name of the file to fetch.
    * @param {boolean} [fatal=true] Whether to throw an error if the file is not found.
    * @param {PretrainedOptions} [options] An object containing optional parameters.
    * @returns {Promise<Object>} The JSON data parsed into a JavaScript object.
    * @throws Will throw an error if the file is not found and `fatal` is true.
    */
    export async function getModelJSON(modelPath, fileName, fatal = true, options = {}) {
    let buffer = await getModelFile(modelPath, fileName, fatal, options);
    if (buffer === null) {
    // Return empty object
    return {}
    }

    let decoder = new TextDecoder('utf-8');
    let jsonData = decoder.decode(buffer);

    return JSON.parse(jsonData);
    }


    I checked the app data and it is indeed not JSON. But this is something I never changed. It just doesnt work on Firebase. It seems, there need to be some more config on Firebase hosting.

    What do you think about?

    Continue reading...

Compartilhe esta Página