maxpozdeev / mytinytodo

Todo list script
156 stars 49 forks source link

'mixed content' error when running with https #52

Closed tribor closed 1 year ago

tribor commented 1 year ago

Version: 1.7.2

I get an error when running on https:

Some error occurred (click for details) Bad connection

It seems that the environment var MTT_USE_HTTPS does not change this behavior when set.

Workaround: insert on the first lines of the file init.php: define("MTT_USE_HTTPS","yes");

Fix: TODO: Check for X-Forwarded-Proto==https or X-Forwarded-For==https ?

maxpozdeev commented 1 year ago

Better to insert the line define("MTT_USE_HTTPS", true); into config.php in the root. In case of init.php you have to edit the file after every version update.

tribor commented 1 year ago

Well, my proposed workaround does not fix the issue. Any plans on working on the X-Forwarded-Proto headers? Or did I get it wrong and the environment variable MTT_USE_HTTPS does work somehow?

maxpozdeev commented 1 year ago

Did you try v1.7.3? Without define("MTT_USE_HTTPS", true); ?

tribor commented 1 year ago

I just tried it with version v1.7.3. The bug is still present. Same error message

Some error occurred (click for details) Bad connection

maxpozdeev commented 1 year ago

Please look at page sources for javascript function $().ready(function(). There should be a line with backend url, looking like "mttUrl": "https://mytinytodo.net/demo/",. Does it have any differences compared to the url of page you open in browser?

tribor commented 1 year ago

my browser is blocking the API-request: mixed block

maxpozdeev commented 1 year ago

Could you please edit the file init.php in the script root folder. On the line 345 (as of v1.7.3) change this code:

$_mttinfo['mtt_url'] = url_dir( get_unsafe_mttinfo('url'), 0 );

to this one:

$_mttinfo['mtt_url'] = url_dir( get_unsafe_mttinfo('url'), 1 );

i.e. replace 0 to 1 in the end.

And check.

maxpozdeev commented 1 year ago

BTW, you should use MTT_USE_HTTPS as constant, not environment variable, i.e. set in config define("MTT_USE_HTTPS", true);

Pay attention to set to true or 1. In the case of "yes", will not work.

tribor commented 1 year ago

Could you please edit the file init.php in the script root folder. On the line 345 (as of v1.7.3) change this code:

$_mttinfo['mtt_url'] = url_dir( get_unsafe_mttinfo('url'), 0 );

to this one:

$_mttinfo['mtt_url'] = url_dir( get_unsafe_mttinfo('url'), 1 );

i.e. replace 0 to 1 in the end.

And check.

I can confirm that this is working now :-)