Skip to content

quarto.js blocked by Cross origin requests policy when not previewing using web server #11904

@cderv

Description

@cderv

With the new way quarto.js works, and how in import tabset.js, Quarto will show console error about loading scripts when opening the HTML file, without having resource embeded.

Access to script at '(...)/index_files/libs/quarto-html/quarto.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.

Image

This happens with Quarto 1.6.40 too.

quarto.js:1 Uncaught SyntaxError: Cannot use import statement outside a module

Image

I am opening this issue in case anyone else is searching for this, as this is new starting from Quarto 1.6. Previously, opening from file system would work, but now, Quarto documents needs to be served (using quarto preview for example) so that they fully works. This was previously required only when using some JS tool that required server (like OJS)

I don't known if we can improve this somehow, but at least this should be documented somewhere... maybe in the FAQ. 🤔
This can be surprising to some users.

(I found this while looking at rich-iannone/DiagrammeR#519 (comment) where quarto preview does not work with some JS lib and opening from file system help)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationDoc improvements & quarto-webhtmlIssues with HTML and related web technology (html/css/scss/js)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions