In a [Solved] thread under the Dev category, jack2 reports that the topic preview feature fails in their local Discourse dev instance running behind an nginx reverse proxy, showing JavaScript errors related to missing modules and failed asset loading. Initially, they tried a workaround suggested by mr8 from a meta thread, which changed the error to a network failure for markdown-it-bundle.js, revealing that Discourse was generating asset URLs pointing to http://127.0.0.1:3000 — an internal server address unreachable by the browser. mr8 suggested disabling plugins and checking app.yml, but jack2 clarified that dev instances don’t use app.yml and confirmed the asset URL issue stems from nginx configuration. riking identified the root cause: missing proxy headers in nginx, specifically X-Forwarded-For and X-Forwarded-Proto, which are required for Discourse to correctly generate public-facing asset URLs. After restoring those headers, jack2 confirmed the fix worked and thanked riking for the solution and the helpful reference link. The issue was ultimately a misconfigured nginx reverse proxy, not a Discourse bug or plugin conflict.
When clicking “New Topic” in my dev instance, I get the following errors in the console and the preview pane doesn’t work:
Uncaught SyntaxError: Unexpected token < markdown-it-bundle.js:1
Error: Could not find module pretty-text/engines/discourse-markdown/helpers discourse/lib/text:40
at missingModule (discourse-loader:134)
at require (discourse-loader:149)
at setup (pretty-text/engines/discourse-markdown-it:242)
at buildOptions (pretty-text/pretty-text:100)
at getOpts (discourse/lib/text:25)
at cook (discourse/lib/text:30)
at eval (discourse/lib/text:38)
at tryCatch (ember:50180)
at invokeCallback (ember:50195)
at publish (ember:50163)
The second error then occurs each time I input a character in the text area.
I believe this problem was not occurring a few months back, but I’m not sure. I’m currently using v1.9.0.beta5 +90.
It hasn’t solve the issue, but the error has changed. I now get:
GET https://127.0.0.1:3000/assets/markdown-it-bundle.js net::ERR_CONNECTION_CLOSED jquery:9245
Error: error ember:19818
at unwrapErrorThrown (ember:33586)
at errorFor (ember:33568)
at onerrorDefault (ember:33558)
at Object.trigger (ember:49836)
at eval (ember:50737)
at invokeWithOnError (ember:2197)
at Queue.flush (ember:2256)
at DeferredActionQueues.flush (ember:2380)
at Backburner.end (ember:2450)
at Backburner.run (ember:2564)
Uncaught promise: {jqXHR: {…}, textStatus: "error", errorThrown: "error"} (index):455
Any idea?
(also, I’ve tried to switch my instance to “force https”, but it made no difference)
I’ve disabled all my plugins and seen no change.
I’m running a dev instance, so I believe there’s no app.yml file.
In the Chrome console, I see Discourse trying to load http://127.0.0.1:3000/assets/markdown-it-bundle.js. Of course, client-side, this url points to nothing.
This url comes from the fact that my nginx is configured like this:
@riking, that did it, thanks a lot. Somewhere along the line I’d commented out my X-Forwarded-For line, for whatever reason.
Thanks also for your excellent link! There’re so many Discourse+nginx pages on this forum (and on the Internet), that it’s good to have a reference one.