DEV: Fix missing port in URLs in development mode.

DEV: Fix missing port in URLs in development mode.

diff --git a/lib/discourse.rb b/lib/discourse.rb
index 51f0e01..b23078c 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -263,6 +263,11 @@ module Discourse
     default_port = SiteSetting.force_https? ? 443 : 80
     url = "#{base_protocol}://#{current_hostname}"
     url << ":#{SiteSetting.port}" if SiteSetting.port.to_i > 0 && SiteSetting.port.to_i != default_port
+
+    if Rails.env.development? && SiteSetting.port.blank?
+      url << ":#{ENV["UNICORN_PORT"] || 3000}"
+    end
+
     url
   end

GitHub sha: b7b99605

1 Like

Hmmmmm is this going to mess up my dev env?

To access dev I type http://l.discourse I run on port 80, unicorn is on 9292.

You’ll have to configure the ENV variable. The problem now is that a non special development environment starts with most links broken due to the missing port.