pereorga / minimalist-web-notepad

Minimalist Web Notepad
https://notes.orga.cat
1.13k stars 282 forks source link

Improvement #54

Closed JMcrafter26 closed 1 year ago

JMcrafter26 commented 1 year ago

No need to enter the base url, just use this instead:

$base_url = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']);

pereorga commented 1 year ago

I like this, and it may work on the vast majority of cases. But I'm thinking it could cause some problems if REQUEST_SCHEME is not set properly (e.g., because TLS is set in a load balancer, CDN, etc.) or when hosted in a sub-subdirectory (e.g. /username/notes/).

It is not ideal to hard code the base URL like I am doing, but I still think it is the easiest and most trouble-free way to do it, considering that the code aims to be as minimal as possible, while trying to be very compatible.

Also, note that $_SERVER['HTTP_HOST'] should be escaped, as it is user input.

JMcrafter26 commented 1 year ago

OK that's sounds reasonable. I made a fork of this, and now it's live-notes. (It's in beta, but it works) Please check it out: https://test.jm26.net/live-notes (I am not uploading this version to github yet, because it has some issues, that may be dangerous for self use)