Base tag injection

Automatically inject html base tag to allow relative referencing of local styles, images or scripts


Set base address in config

"extensions": {
  "base": {
    "url": "${cwd}/myAssets"
  "trustUserCode": true

The extension then injects html base tag into every valid html:

    <base href="file:///jsreportFolder/myAssets" />
    <script src="js/jquery.min.js"></script>

The base tag assures that relatively linked scripts, images or styles gets loaded from the specified folder without additional extra work. Only note that you need to allow users to reach the local system through the trustUserCode: true.

Send base address when running through cli

jsreport render

Send base address as part of the api request

POST: http://localhost:5488/api/report
Headers: Content-Type: application/json

  "template": {
    "content": "<html><head></head><body></body></html>",
    "recipe": "html",
    "engine": "handlebars"
  "options": {
    "base": ""

jsreport version