Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixed `Store#formatted_url` for localhost

Damian Legawiecd2a222705801
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rb
index 0a2667ac51..3bdd08f210 100644
--- a/core/app/models/spree/store.rb
+++ b/core/app/models/spree/store.rb
@@ -265,15 +265,16 @@ module Spree
def formatted_url
@formatted_url ||= if Rails.env.development? || Rails.env.test?
scheme = Rails.application.routes.default_url_options[:protocol] || :http
+ port = Rails.application.routes.default_url_options[:port].presence || (Rails.env.development? ? 3000 : nil)
if scheme.to_sym == :https
URI::HTTPS.build(
host: url.to_s.sub(%r{^https?://}, ''),
- port: Rails.application.routes.default_url_options[:port]
+ port: port
).to_s
else
URI::HTTP.build(
host: url.to_s.sub(%r{^https?://}, ''),
- port: Rails.application.routes.default_url_options[:port]
+ port: port
).to_s
end
else