1

I've just started studying DocFX. According to its official guide we build content with a command similar to docfx docfx.json --serve and then view the generated site from http://localhost:8080. My question is: if DocFX is a static site generator, why does it serve content via a web server? Why does it not just say click index.html to view the generated site ? Is there a difference?

Tekins
  • 119
  • 10
  • I normally 'serve' docfx content from inside Visual Studio, where opening an HTML file opens it for editing, and doesn't render it. To render the pages, without the build-int web server, I would have to run my 'docs' web app, which prevents me from running the app I'm actually working on. – ProfK Aug 08 '21 at 00:55

1 Answers1

0

DocFX does generate static content, however the main index.html page will attempt to load some assets such as table of contents (toc.html) using an XMLHttpRequest from the browser. Such requests will be blocked by the browser if you have loaded the site by opening the index.html page from disk.

If you try, run the F12 dev tools in Chrome (or browser of your choice) and you will see warnings such as:

Access to XMLHttpRequest at 'file:///your-path/_site/toc.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https.

As a result, the site really needs to be loaded from a web server over HTTP to get the best result

lowds
  • 1,085
  • 8
  • 12