0

I'm using a reverse proxy (http-proxy-middleware) with Node.js to load in an instance of NodeBB.

Website URL - www.website.com/forums/ Forum URL - forum.website.com/forums/

I can't log in to the forum via the website URL (www.website.com/forums/login/)

I either experience a login form post timeout or a session mismatch error.

I can log in directly to the forum via the forum URL (forum.website.com/forums/login), but because of the config.json setup (to allow NodeBB to run on another domain), there is a problem with WebSocket and invalid sessions there.

NodeBB is running from environment variables, key:value as follows:

"url": "http://www.website.com/forums/",
"secret": "SECRET",
"database": "postgres",
"port": "4567",
"postgres__host": "HOST",
"postgres__port": 5432,
"postgres__username": "USER",
"postgres__password": "PASSWORD",
"postgres__database": "DB"

What config settings are missing to be able to fix this? And more importantly, how can they be set as environment variables?

danlong
  • 880
  • 1
  • 8
  • 21

1 Answers1

0

The problem wasn't to do with NodeBB, it was to do with the Node.js proxy (http-proxy-middleware)

The POST request wasn't being proxied to the server, because of the 'body-parser' being declared before my proxy server.

So the fix was to move my Proxy definition and routes above the 'body-parser' module.

Fix is detailed in here - https://github.com/chimurai/http-proxy-middleware/issues/40#issuecomment-163398924

danlong
  • 880
  • 1
  • 8
  • 21