Postleaf / postleaf

Simple, beautiful publishing with Node.js.
https://www.postleaf.org/
MIT License
505 stars 204 forks source link

Wrong css links #81

Closed kfo1182 closed 6 years ago

kfo1182 commented 6 years ago

Summary

CSS links in a fresh install don't include the port number. To make them work, one should either edit the code by hand, or start postleaf on the port 80 - with sudo.

Steps to Reproduce

  1. Install postleaf according to instruction.
  2. Set APP_URL=http://localhost APP_PORT=3000 APP_HOST=localhost in the .env file.
  3. Start postleaf and go to http://localhost:3000/admin
  4. Manually replacing href="{@url...}" in views with href="/..." resolves the problem.

Additional info


Note: This issue tracker is ONLY for bug reports and feature requests. If this is a personal support issue, please visit postleaf.org/support.

claviska commented 6 years ago

If you’re running Postleaf locally, the solution is to include the port number in APP_URL in your .env file:

APP_URL=http://localhost:3000/

This only affects local installs, as most production installs are proxied behind Nginx or Apache.

kfo1182 commented 6 years ago

I certainly do the same thing on the production server. However, if there is an .env variable - why not use it? It wouldn't break reverse proxying, since nginx internally adresses node app with a port specified, but will fix the dev-server deployment. Current version of .env seems to be confusing. PS: Thank you, now I have a fully functional dev server, so it isn't my issue anymore. You can read this comment as a rhetoric question.

claviska commented 6 years ago

It’s because APP_URL is strictly used to generate URLs.

Postleaf has no way of knowing whether not the port should be included in the URL (not all dev environments will require it.)

This has been a point of confusion for some people but I’m not sure what the best solution is. Open to ideas!

kfo1182 commented 6 years ago

For any practical reason, do you have to know APP_URL to generate hrefs for stattic assets? Do I miss something, or could you refactor .env variables in the following way: APP_URL dissapears, since you can always link static assets relatively to the host, or ask your node.js instance what the host is. If there is a need to run postleaf in a domain subfolder, you could create an APP_DOMAIN_SUBFOLDER var (i.e. =/blog/), and concatenate it with relative urls. APP_HOST and APP_PORT stay what they are - settings to start up a node.js server.

Whatever the .env format gonna be, it may be helpful to leave some comments in .env.example.

Sorry if overlooked something obvious and am just wasting your time.

claviska commented 6 years ago

There are a handful of reasons we need to know the host (password reset emails, for example).

In the PHP version of Postleaf (now forked and called Leafpub), we moved to schemaless URLs but that change was reverted for the same reason.

Again, maybe .env isn't the best place for it. Maybe the proxy should be required to pass the hostname to the app (but then you'd still need to make it available in dev somehow). This approach just seemed practical at the time.

claviska commented 6 years ago

Closing this as the solution is mentioned above.