Hello, i have deployed mattermost-server
to my own server on DigitalOcean, and then i cloned mattermost-webapp
. My question is how to connect local webapp at http://localhost:9005
to remote server API. Thank you
After finding the answer from mattermost community, i knew an alternative way using Charles: but i think this is not convenient, official way.
After some hours researching, i found a way to set the remote API in components/root/root.jsx
constructor(props) {
super(props);
this.currentCategoryFocus = 0;
this.currentSidebarFocus = 0;
// Redux
// setUrl(getSiteURL());
setUrl('http://this.is.my.ip');
and in actions/websocket_actions.jsx
const config = getConfig(getState());
let connUrl = '';
if (config.WebsocketURL) {
connUrl = config.WebsocketURL;
} else {
// connUrl = new URL(getSiteURL());
connUrl = new URL('http://this.is.my.ip');
Everything seems work fine but it always be logged out after I refreshed page.
Does anyone get this problem?
You could ask about this on our Community serverâs Peer-to-peer channel here. Iâm not sure how to help with this issue, but one of our developers or other community members might.
I have posted to Peer-to-peer but got no help
I found the problem, when we refresh page, we load MMUSERID
from document.cookie
, but it belong to domain this.is.my.ip
, not localhost
, so we can not get MMUSERID
, so we have to login again.
I havenât found anyway workaround
@huy-lv, Iâm not sure there is an âofficial supportedâ way to do this. The Charles approach will work, but agree itâs not super convenient. There is also the npm run dev-server
option which you can hack to point at an arbitrary upstream, but I donât know how well it works.
Feel free to reach out on https://community-daily.mattermost.com/core/channels/developers to see if any of the other developers have insights to offer
I have found a workaround make it work, just remove these line from actions/views/root.js
if (document.cookie.indexOf('MMUSERID=') > -1) {
resolvedPromises.push(await dispatch(UserActions.loadMe()));
}
This may leads some bugs, really need help from our author