Is it possible to run Discourse in a headless mode i.e. without the Ember frontend?
AI-generated summary
The discussion revolves around running Discourse in a headless mode, without the Ember frontend. jamesmarkcook wants to achieve this for their React frontend consuming the Discourse API, as they don’t want users to see the unbranded Discourse Ember frontend when visiting their ‘API’ url. Falco suggests setting a custom header when calling the Discourse API and adding a rule on the internal Discourse nginx to 403 all requests without the special header. Falco further explains how to implement this using the official Discourse docker images by modifying the app.yml file to replace a section in the nginx configuration file, providing examples from the Discourse Docker repository.
Recategorizing to #installation as this definitely isn’t a frequently asked question.
Could you elaborate on your use case?
We have a React frontend consuming the Discourse API. We also have our own plugin extending Discourse features for some specific use cases.
If users visit our ‘API’ url then they currently see the unbranded Discourse Ember frontend. Ideally we’d like to turn that off.
I would make my custom app set a custom header when calling the Discourse API, and add a small rule on the internal Discourse nginx to 403 all requests without the special header.
Thanks for the suggestion @Falco. What would be the best way to do this whilst still using the official Discourse docker images?
You can do the necessary mangling on your app.yml file.
The app.yml file you have now should be ending like this:
run:
- exec: echo "Beginning of custom commands"
## blablabla
- exec: echo "End of custom commands"
You can run replaces in the nginx file making it look like this
run:
- exec: echo "Beginning of custom commands"
## blablabla
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: "location @discourse {"
to: |
location @discourse {
add_header AAA bbb;
- exec: echo "End of custom commands"
There are several examples at discourse_docker/templates at master · discourse/discourse_docker · GitHub