Bookdown search worked in IDE but not in browser

I was building a bookdown website, I hit the "Build Book" button, a window with the book popped up and the search function worked just fine there.

I clicked "Open in Browser" to test the site in Firefox and now the search function didn't work.

I tried to open the rendered index.html file in the _book folder on both Chrome and Firefox and still got the same bug.

I can't figure it out what was wrong. I'm not good with words so here is a captured screencast of what was happened:

https://youtu.be/rrMrQ7liHNo

I ran into this issue a while ago and if my memory is correct, the search only works when the book is hosted/published. For example, if you had it on Posit Connect , GitHub Pages, etc.
When you see the preview in the IDE it's like a "temporary publish" so the search works.

1 Like

Correct. Browsers have a security feature now that requires JavaScript files to be loaded from the same domain or something like that. When you open a local file there is no domain, so some things don’t work.

1 Like

Ah yes, that's right. Thank you for your help.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.