NodeBB API requests: CORS problems

Technical Support
  • Hello,

    I am building a web site that exposes news and stuff like that, and I would like to use nodeBB as a back-office.
    What I actually want to do is, to list the 5 latests topics of a category and then display the first post on my web site (also list the number of comments, who has posted the topic, etc...)

    I hava already seen that we can use the /api/category route to get all the categories of the forum and also /api/topic/{id} to get the topic we want.

    The problem is, I have some issues with the CORS headers. The error that chrome tells me:

    Failed to load https://[site].com/api/category/1: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

    Do you have any idea how I can consume the NodeBB API throught another website ? (website built with Angular in my case).

    Thanks in advance 😄

  • You can configure the cors header in the NodeBB admin panel or with your reverse proxy.

  • Thank you for your answer. I have configured the CORS headers on my reverse proxy (nginx) and it works well now.

    Thank you!

Suggested Topics