Skip to content

When using relative root, pdfjs javascript assets do not load correctly #74

@Alfeezy

Description

@Alfeezy

I'm sure there's something I'm overlooking here, but I haven't found a solution yet so I'll stick this here.

I have an application which uses a relative url for the production environment:
Rails.application.config.action_controller.relative_url_root = "/myrelativeroot"

When loading a pdf in development, everything works as intended. However, when I try to do the same in production, I get the following error from the js console:

Loading Worker from “https://mywebsite/pdfjs/web/pdf.worker.js?version=1.10.100” was blocked because of a disallowed MIME type (“text/html”)

It turns out, this file doesn't exists. However, when I go to https://mywebsite/myrelativeroot/pdfjs/web/pdf.worker.js?version=1.10.100, the file can be found just fine. Somehow, I need to tell pdfjs to append the relative url in the right spot to find pdf.worker.js.

# routes.rb
mount PdfjsViewer::Rails::Engine => "pdfjs", as: 'pdfjs'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions