enabling assets_publicAccessEnabled and running in docker container



  • Hi,

    I have a template which references an asset via a link as such: <script src="{#asset myAsset.js @encoding=link}"></script>

    When deploying to non-local environments (ex: qa), I set extensions_assets_rootUrlForLinks to an appropriate server containing my assets in /assets/content/ and everything works as expected.

    However, when locally running via docker, I do not set the rootUrlForLinks and expect asset to be loaded from my localhost similar to http://localhost:[PORT]/assets/content/myAsset.js

    When debugging the report i see the following error when trying to retrieve the asset:
    Page request failed: GET (script) http://localhost:[PORT]/assets/content/myAsset.js, failure: net::ERR_CONNECTION_REFUSED

    Assuming this is because the publicAccessEnabled flag isn't set, I try setting that but when I do I am unable to start the report server with the following error on startup:

    web_1  | 2020-10-20T16:49:42.347Z - error: Error occured during reporter init TypeError: Cannot read property 'publicRoutes' of undefined
    web_1  |     at Reporter.<anonymous> (/app/node_modules/jsreport-express/lib/routes.js:12:73)
    web_1  |     at Reporter.emit (events.js:311:20)
    web_1  |     at Reporter.EventEmitter.emit (domain.js:482:12)
    web_1  |     at Function.<anonymous> (/app/node_modules/jsreport-assets/lib/assets.js:415:16)
    web_1  |     at /app/node_modules/listener-collection/lib/listenerCollection.js:171:33
    web_1  |     at /app/node_modules/listener-collection/lib/listenerCollection.js:151:16
    web_1  |     at tryCatcher (/app/node_modules/listener-collection/node_modules/bluebird/js/release/util.js:16:23)
    web_1  |     at Promise._settlePromiseFromHandler (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:512:31)
    web_1  |     at Promise._settlePromise (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:569:18)
    web_1  |     at Promise._settlePromise0 (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:614:10)
    web_1  |     at Promise._settlePromises (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:693:18)
    web_1  |     at Async._drainQueue (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:133:16)
    web_1  |     at Async._drainQueues (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:143:10)
    web_1  |     at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:17:14)
    web_1  |     at processImmediate (internal/timers.js:456:21)
    web_1  |     at process.topLevelDomainCallback (domain.js:137:15)
    web_1  | TypeError: Cannot read property 'publicRoutes' of undefined
    web_1  |     at Reporter.<anonymous> (/app/node_modules/jsreport-express/lib/routes.js:12:73)
    web_1  |     at Reporter.emit (events.js:311:20)
    web_1  |     at Reporter.EventEmitter.emit (domain.js:482:12)
    web_1  |     at Function.<anonymous> (/app/node_modules/jsreport-assets/lib/assets.js:415:16)
    web_1  |     at /app/node_modules/listener-collection/lib/listenerCollection.js:171:33
    web_1  |     at /app/node_modules/listener-collection/lib/listenerCollection.js:151:16
    web_1  |     at tryCatcher (/app/node_modules/listener-collection/node_modules/bluebird/js/release/util.js:16:23)
    web_1  |     at Promise._settlePromiseFromHandler (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:512:31)
    web_1  |     at Promise._settlePromise (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:569:18)
    web_1  |     at Promise._settlePromise0 (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:614:10)
    web_1  |     at Promise._settlePromises (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:693:18)
    web_1  |     at Async._drainQueue (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:133:16)
    web_1  |     at Async._drainQueues (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:143:10)
    web_1  |     at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:17:14)
    web_1  |     at processImmediate (internal/timers.js:456:21)
    web_1  |     at process.topLevelDomainCallback (domain.js:137:15)
    

    this is the (simplified for testing) docker file i am using along with the docker-compose.yml

    #DOCKERFILE
    FROM jsreport/jsreport:2.10.0-full
    
    //docker-compose.yml
    version: "3.8"
    services:
      web:
        build: .
        ports:
          - "5490:5488"
        environment:
          - extensions_assets_publicAccessEnabled=true
          - extensions_assets_searchOnDiskIfNotFoundInStore=true
    

    Thanks in advance for any thoughts or insights in how I can work to resolve this issue.

    Thank you



  • I fixed the Cannot read property publicRoutes of undefined error in our git master branch, but I'm afraid its unrelated.
    The publicAccessEnabled exposes the assets to the public if you use jsreport authentication extension.
    I believe you don't have it enabled. So this won't help anyway.

    The problem could be what you set to the extensions_assets_rootUrlForLinks.
    This URL is used from inside of the docker container to reach the jsreport server.
    This means the port should be the local one 5488.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.