quarto-dev / quarto-dev/quarto-cli

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

Open
#11,904 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation html
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

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 https://github.com/rich-iannone/DiagrammeR/issues/519#issuecomment-1959744895 where quarto preview does not work with some JS lib and opening from file system help)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with a generated HTML file opened directly, comparing it with quarto preview, and review the quarto.js and tabset.js loading context. Document that Quarto 1.6 documents using these scripts need to be served, including the quarto preview workaround and the limitations of file-system opening; the FAQ is suggested as a possible location.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.