qdm12 / stackedit-docker

StackEdit 5.14.5 Server in a light Docker container
https://hub.docker.com/r/qmcgaw/stackedit
MIT License
42 stars 16 forks source link

Support lading page #5

Closed yohanyflores closed 4 years ago

yohanyflores commented 4 years ago

More routing options, based on the original server https://github.com/benweet/stackedit/blob/master/server/index.js

qdm12 commented 4 years ago

Thanks a lot :+1: I'll rework the long overdue Dockerfile and CI this evening as well. Enjoy!

qdm12 commented 4 years ago

Hey there, I added some changes to the Go code and the Dockerfile. Would you mind testing the latest docker image to see if everything works as expected for you? Maybe I missed something re-writing the Go code.

Also what's at the path /conf or /app/conf? I see you return a constant, what should be returned here? Do you have a link on the configuration settings / environment variables Stackedit reads? I would be happy to add them. Thanks!

yohanyflores commented 4 years ago

Hi :), thanks for asking me.

Regarding the golang code, I don't understand what the rootUrl variable does. Since if this variable is different from "" or "/", errors appear.

The Dockerfile is wired to /html/static and /html/dist so any value of rootUrl other than "" or "/"causes the files in path variable not to be served correctly. It should not be used to build the path variable. This is wrong path = rootURL +"/dist/xxxxxxx ".

In addition to tests performed, it seems that stackedit cannot be executed in a folder or context other than the root (I seemed to see that it is wired to /). Unless changes are made to the static files or the route handles it correctly without interfering with other applications.

In relation to /conf, the server must build a JSON, using the environment variables that you already defined: DROPBOX_APP_KEY, GITHUB_CLIENT_ID, WORDPRESS_CLIENT_ID, etc.

qdm12 commented 4 years ago

Yeah oops! I fixed it now (locally), but indeed Stackedit does not seem friendly to run with a different root URL. I am trying to debug what routes are missing, as I would really like not to have a subdomain just for Stackedit personnally 😄

I've added also the json response of all the Stackedit related environment variables.

qdm12 commented 4 years ago

Hi again,

It finally works, you can now set ROOT_URL=stackedit for example, and you could then access it from http://localhost:8000/stackedit without issue.

It also returns a JSON value from the environment variables at /conf as you mentioned in your TODO.

Happy stackediting!

yohanyflores commented 4 years ago

Wow .... Already perform the tests and it works perfectly. Thank you.

yohanyflores commented 4 years ago

The only problem is that stackedit asks for resources outside of ROOT_URL=/stackedit/, such as:

http://localhost:8002/static/css/app.5eefa31cb301f3c2eb7a6ca9f02b8b12.css

and not as expected

http://localhost:8002/stackedit/static/css/app.5eefa31cb301f3c2eb7a6ca9f02b8b12.css

This can be a problem, when using a reverse proxy. As is my case, I can only modify the assigned context, /stackedit/.

But if you use this server directly you would have no problem.

qdm12 commented 4 years ago

Indeed, I am trying to fix it as it works locally but not with a reverse proxy.

I'm still a bit confused why though, is it URL values in the generated Javascript? I could do some ugly replace all for all relative URLs adding ROOT_URL in front if that's the case.