Rocket.chat: CORS broken: OPTIONS requests returns 500 Internal Server Error

Created on 27 Aug 2017  路  6Comments  路  Source: RocketChat/Rocket.Chat

Rocket.Chat version: 0.58.0

Anyway, I am trying to make an API call from the browser. It sends an OPTIONS request before POST to /api/logon to check CORS. The thing is, I am getting 500 Internal Server Error on this OPTIONS request, which is rendering Rocket Chat impossible to access from the browser.

Most helpful comment

screenshot from 2017-08-30 13-49-09
I set "Enable CORS" in General Option tab of admin account, but still getting 500 errors
I use Docker compose to run RocketChat

All 6 comments

This is an option in the library we are using (restivus) and it's disabled.
We can create an option to enable it on admin panel.

screenshot from 2017-08-30 13-49-09
I set "Enable CORS" in General Option tab of admin account, but still getting 500 errors
I use Docker compose to run RocketChat

Hello, is there any further feedback on this? I am also receiving a 500 Internal Server Error when hitting the REST API through a browser as it sends the OPTIONS request first.

Hi @ramdesh, Have you solve your problem ? I got the same here.

@huynhquocmy, no - it seems it requires a code change on the server itself. I overcame this problem by implementing a node.js based middleware that routes requests from the UI to the chat server.

Thanks @ramdesh , I solved problem already.

I workaround by changed RocketChat.API.v1 = new API({
version: 'v1',
useDefaultAuth: true,
prettyJson: true,
enableCors: true,
auth: getUserAuth()
});

RocketChat.API.default = new API({
useDefaultAuth: true,
prettyJson: true,
enableCors: true,
auth: getUserAuth()
});

manually set enableCors: true from the file

packages\rocketchat-api\server\api.js
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mddvul22 picture mddvul22  路  3Comments

tanc picture tanc  路  3Comments

ghost picture ghost  路  3Comments

karlprieb picture karlprieb  路  3Comments

zeigerpuppy picture zeigerpuppy  路  3Comments