sugarizer-server icon indicating copy to clipboard operation
sugarizer-server copied to clipboard

401 unauthorized error with activity reorder by drag and drop feature

Open saga0p opened this issue 3 years ago • 4 comments

401 unauthorized error while reordering the activities by drag and drop feature POST http://localhost:8080/api/v1/activities?x_key=623a00c1a8337755841ca9c9&access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0aWFsIjpmYWxzZSwiZXhwIjoxNjQ5MTAzMTU1OTg0fQ.EKcOL1VD-v6FSrMELDfBRoiLM9sDOiamDEUSTzwx_1A 401 (Unauthorized) And because of that the progress is not getting saved I would like to fix this issuealongside with issue #322 , as both are similar

saga0p avatar Apr 03 '22 13:04 saga0p

I can't reproduce the issue on my side, could you detail your environment?

llaske avatar Jul 21 '22 20:07 llaske

Closed due to lack of activity.

llaske avatar Feb 04 '23 09:02 llaske

I just encountered a similar problem today when trying to re-arrange and limit the activities in the dashboard. It seemed like I was having issues with it not saving, but I didn't think to look in the console until I found this issue in the repo. Upon inspection, I was not getting a 401 - but connection refused.

I am connected to my server that is running on my network: http://10.0.0.11:8080

However, I noticed the error is actually being caused by the web app attempting to use the wrong URL - it is trying to use the API from http://localhost:8080! image

I dug into the code a bit, and it appears that localhost is actually hard coded... https://github.com/llaske/sugarizer-server/blob/master/dashboard/helper/common.js#L103


Might I suggest either getting this info from window.location or adding a new ini configuration?

./dashboard/helper/commons.js

exports.getAPIUrl = function() {
        return (ini.security.https ? 'https' : 'http' ) + "://" + ini.web.hostname + ":" + ini.web.port + '/';
};

./env/sugarizer.ini

[web]
hostname = 10.0.0.11
port = 8080

I did the above changes (adding new web.hostname ini configuration) and now I am able to modify the activities! image

korgon avatar Aug 17 '23 06:08 korgon

Good point @korgon :+1: It's a bug. I can reproduce it on the dev platform where localhost is use too:

image

BTW I'm not sure about the cause, why it happens only on the activities screen? :thinking:

llaske avatar Aug 18 '23 17:08 llaske