Trouble accessing local files



  • Hello there,

    I'm trying to access local files using a handlebars template. I'm able to compile the template and render it in Express. When I try to convert that rendered HTML into a PDF using jsreport programmatically. I get the following error in the console:

    Page request failed: GET (stylesheet) file:///styles/cover.css, failure: net::ERR_FILE_NOT_FOUND

    Here's how I'm linking the stylesheet:

    <link rel='stylesheet' href='/styles/cover.css' />

    I'm trying to use jsreport programmatically without the studio. So I can't use jsreport syntax as compiling handlebars in Express won't understand it. Handlebars is able to find the local files and they render in HTML just fine. JsReport didn't have access to local files at first, but then I turned "allowLocalFileAccess
    " on, and it's not able to find them. Is there a way I can instruct jsreport where to look similar to
    app.use(express.static(__dirname + '/views')) ?

    Thanks



  • You can use html base tag
    https://www.w3schools.com/tags/tag_base.asp

    <base href="file:///pathToYourApp" >
    

    Then all your html refs should target to your app folder.



  • Thank you, that worked!


Log in to reply
 

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