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.

Use port 3000 by default, set only CDN host when present (#12016)

Damian Legawiecb1d347e7d2d4
diff --git a/api/docs/oauth/index.yml b/api/docs/oauth/index.yml
index 36a9ef3dec..d13546f117 100644
--- a/api/docs/oauth/index.yml
+++ b/api/docs/oauth/index.yml
@@ -2,7 +2,7 @@ openapi: 3.0.3
servers:
- url: 'https://demo.spreecommerce.org'
description: demo
- - url: 'http://localhost:4000'
+ - url: 'http://localhost:3000'
description: localhost
info:
version: 1.0.0
diff --git a/api/docs/v2/platform/index.yaml b/api/docs/v2/platform/index.yaml
index 88e38c6da7..200614dd7b 100644
--- a/api/docs/v2/platform/index.yaml
+++ b/api/docs/v2/platform/index.yaml
@@ -17951,7 +17951,7 @@ servers:
- url: http://{defaultHost}
variables:
defaultHost:
- default: localhost:4000
+ default: localhost:3000
tags:
- name: Addresses
- name: Adjustments
diff --git a/api/docs/v2/storefront/index.yaml b/api/docs/v2/storefront/index.yaml
index 979c381e52..40dae3b4ab 100644
--- a/api/docs/v2/storefront/index.yaml
+++ b/api/docs/v2/storefront/index.yaml
@@ -2,7 +2,7 @@ openapi: 3.0.3
servers:
- url: 'https://demo.spreecommerce.org'
description: demo
- - url: 'http://localhost:4000'
+ - url: 'http://localhost:3000'
description: localhost
info:
version: 2.0.0
@@ -2540,7 +2540,7 @@ components:
properties:
url:
type: string
- example: 'http://localhost:4000/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJbWQyWVhKcFlXNTBjeTltWm1sMmRURlNORFpZWjJaSFpYUkdZMjk2WWsxM1RHWXZNVGs1T1RCak5XVmlNamN4TlRnd1pqVTBabUpqTWpCbFkyVXhZMlZpTTJFd05ERTJZemMzT0dKaE5tSTFNREkyT0dKaFpqa3paV1JtWTJWaE16aGxaQVk2QmtWVSIsImV4cCI6IjIwMTgtMDYtMjRUMTM6NTk6NTguOTY5WiIsInB1ciI6ImJsb2Jfa2V5In19--5e9ff358dc747f73754e332678c5762114ac6f3f/ror_jr_spaghetti.jpeg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22ror_jr_spaghetti.jpeg%22%3B+filename%2A%3DUTF-8%27%27ror_jr_spaghetti.jpeg'
+ example: 'http://localhost:3000/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJbWQyWVhKcFlXNTBjeTltWm1sMmRURlNORFpZWjJaSFpYUkdZMjk2WWsxM1RHWXZNVGs1T1RCak5XVmlNamN4TlRnd1pqVTBabUpqTWpCbFkyVXhZMlZpTTJFd05ERTJZemMzT0dKaE5tSTFNREkyT0dKaFpqa3paV1JtWTJWaE16aGxaQVk2QmtWVSIsImV4cCI6IjIwMTgtMDYtMjRUMTM6NTk6NTguOTY5WiIsInB1ciI6ImJsb2Jfa2V5In19--5e9ff358dc747f73754e332678c5762114ac6f3f/ror_jr_spaghetti.jpeg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22ror_jr_spaghetti.jpeg%22%3B+filename%2A%3DUTF-8%27%27ror_jr_spaghetti.jpeg'
description: Absolute URL of the uploaded image in selected style (width/height)
width:
type: integer
@@ -4818,11 +4818,11 @@ components:
total_count: 1
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/account/orders'
- next: 'http://localhost:4000/api/v2/storefront/account/orders?page=1'
- prev: 'http://localhost:4000/api/v2/storefront/account/orders?page=1'
- last: 'http://localhost:4000/api/v2/storefront/account/orders?page=1'
- first: 'http://localhost:4000/api/v2/storefront/account/orders?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/account/orders'
+ next: 'http://localhost:3000/api/v2/storefront/account/orders?page=1'
+ prev: 'http://localhost:3000/api/v2/storefront/account/orders?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/account/orders?page=1'
+ first: 'http://localhost:3000/api/v2/storefront/account/orders?page=1'
Including all related objects:
value:
data:
@@ -5093,11 +5093,11 @@ components:
total_count: 1
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/account/orders?include=line_items,variants,variants.images,billing_address,shipping_address,user,payments,shipments,promotions'
- next: 'http://localhost:4000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
- prev: 'http://localhost:4000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
- last: 'http://localhost:4000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
- first: 'http://localhost:4000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
+ self: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items,variants,variants.images,billing_address,shipping_address,user,payments,shipments,promotions'
+ next: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
+ prev: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
+ last: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
+ first: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
User:
description: 200 Success - Returns the `user` object.
content:
@@ -5268,11 +5268,11 @@ components:
total_count: 3
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/account/addresses'
- next: 'http://localhost:4000/api/v2/storefront/account/addresses?page=1'
- prev: 'http://localhost:4000/api/v2/storefront/account/addresses?page=1'
- last: 'http://localhost:4000/api/v2/storefront/account/addresses?page=1'
- first: 'http://localhost:4000/api/v2/storefront/account/addresses?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/account/addresses'
+ next: 'http://localhost:3000/api/v2/storefront/account/addresses?page=1'
+ prev: 'http://localhost:3000/api/v2/storefront/account/addresses?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/account/addresses?page=1'
+ first: 'http://localhost:3000/api/v2/storefront/account/addresses?page=1'
Address:
description: 200 Success - Returns the `address` object.
content:
@@ -5716,11 +5716,11 @@ components:
total_count: 6
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/cms_pages'
- next: 'http://localhost:4000/api/v2/storefront/cms_pages?page=1'
- prev: 'http://localhost:4000/api/v2/storefront/cms_pages?page=1'
- last: 'http://localhost:4000/api/v2/storefront/cms_pages?page=1'
- first: 'http://localhost:4000/api/v2/storefront/cms_pages?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/cms_pages'
+ next: 'http://localhost:3000/api/v2/storefront/cms_pages?page=1'
+ prev: 'http://localhost:3000/api/v2/storefront/cms_pages?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/cms_pages?page=1'
+ first: 'http://localhost:3000/api/v2/storefront/cms_pages?page=1'
CMS Pages with Included Sections:
value:
data:
@@ -6215,11 +6215,11 @@ components:
total_count: 6
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/cms_pages?include=cms_sections'
- next: 'http://localhost:4000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
- prev: 'http://localhost:4000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
- last: 'http://localhost:4000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
- first: 'http://localhost:4000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
+ self: 'http://localhost:3000/api/v2/storefront/cms_pages?include=cms_sections'
+ next: 'http://localhost:3000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
+ prev: 'http://localhost:3000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
+ last: 'http://localhost:3000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
+ first: 'http://localhost:3000/api/v2/storefront/cms_pages?include=cms_sections&page=1'
CreditCard:
description: 200 Success - Returns the `credit_card` object.
content:
@@ -6329,11 +6329,11 @@ components:
total_count: 2
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/account/credit_cards'
- next: 'http://localhost:4000/api/v2/storefront/account/credit_cards?page=0'
- prev: 'http://localhost:4000/api/v2/storefront/account/credit_cards?page=1'
- last: 'http://localhost:4000/api/v2/storefront/account/credit_cards?page=0'
- first: 'http://localhost:4000/api/v2/storefront/account/credit_cards?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/account/credit_cards'
+ next: 'http://localhost:3000/api/v2/storefront/account/credit_cards?page=0'
+ prev: 'http://localhost:3000/api/v2/storefront/account/credit_cards?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/account/credit_cards?page=0'
+ first: 'http://localhost:3000/api/v2/storefront/account/credit_cards?page=1'
Product:
description: 200 Success - Returns the `product` object.
content:
@@ -8566,11 +8566,11 @@ components:
- value: Zeta
filter_param: zeta
links:
- self: 'http://localhost:4000/api/v2/storefront/products'
- next: 'http://localhost:4000/api/v2/storefront/products?page=2'
- prev: 'http://localhost:4000/api/v2/storefront/products?page=1'
- last: 'http://localhost:4000/api/v2/storefront/products?page=5'
- first: 'http://localhost:4000/api/v2/storefront/products?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/products'
+ next: 'http://localhost:3000/api/v2/storefront/products?page=2'
+ prev: 'http://localhost:3000/api/v2/storefront/products?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/products?page=5'
+ first: 'http://localhost:3000/api/v2/storefront/products?page=1'
Store:
description: 200 Success - Returns the `store` object.
content:
@@ -11930,11 +11930,11 @@ components:
total_count: 26
total_pages: 2
links:
- self: 'http://localhost:4000/api/v2/storefront/taxons'
- next: 'http://localhost:4000/api/v2/storefront/taxons?page=2'
- prev: 'http://localhost:4000/api/v2/storefront/taxons?page=1'
- last: 'http://localhost:4000/api/v2/storefront/taxons?page=2'
- first: 'http://localhost:4000/api/v2/storefront/taxons?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/taxons'
+ next: 'http://localhost:3000/api/v2/storefront/taxons?page=2'
+ prev: 'http://localhost:3000/api/v2/storefront/taxons?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/taxons?page=2'
+ first: 'http://localhost:3000/api/v2/storefront/taxons?page=1'
Country:
description: 200 Success - Returns the `country` object.
content:
@@ -15236,11 +15236,11 @@ components:
total_count: 240
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/countries'
- next: 'http://localhost:4000/api/v2/storefront/countries?page=1&per_page=240'
- prev: 'http://localhost:4000/api/v2/storefront/countries?page=1&per_page=240'
- last: 'http://localhost:4000/api/v2/storefront/countries?page=1&per_page=240'
- first: 'http://localhost:4000/api/v2/storefront/countries?page=1&per_page=240'
+ self: 'http://localhost:3000/api/v2/storefront/countries'
+ next: 'http://localhost:3000/api/v2/storefront/countries?page=1&per_page=240'
+ prev: 'http://localhost:3000/api/v2/storefront/countries?page=1&per_page=240'
+ last: 'http://localhost:3000/api/v2/storefront/countries?page=1&per_page=240'
+ first: 'http://localhost:3000/api/v2/storefront/countries?page=1&per_page=240'
Shipment:
description: '200 Success - Returns an array containing several `shipment` objects, along with the included array containing all available `shipping_rate` and `stock_location` objects. '
content:
@@ -16243,11 +16243,11 @@ components:
total_count: 2
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/menus'
- next: 'http://localhost:4000/api/v2/storefront/menus?page=1'
- prev: 'http://localhost:4000/api/v2/storefront/menus?page=1'
- last: 'http://localhost:4000/api/v2/storefront/menus?page=1'
- first: 'http://localhost:4000/api/v2/storefront/menus?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/menus'
+ next: 'http://localhost:3000/api/v2/storefront/menus?page=1'
+ prev: 'http://localhost:3000/api/v2/storefront/menus?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/menus?page=1'
+ first: 'http://localhost:3000/api/v2/storefront/menus?page=1'
Wishlist:
description: 200 Success - Returns the `wishlist` object.
content:
@@ -16385,11 +16385,11 @@ components:
total_count: 3
total_pages: 1
links:
- self: 'http://localhost:4000/api/v2/storefront/wishlists?is_variant_included=150'
- next: 'http://localhost:4000/api/v2/storefront/wishlists?page=1'
- prev: 'http://localhost:4000/api/v2/storefront/wishlists?page=1'
- last: 'http://localhost:4000/api/v2/storefront/wishlists?page=1'
- first: 'http://localhost:4000/api/v2/storefront/wishlists?page=1'
+ self: 'http://localhost:3000/api/v2/storefront/wishlists?is_variant_included=150'
+ next: 'http://localhost:3000/api/v2/storefront/wishlists?page=1'
+ prev: 'http://localhost:3000/api/v2/storefront/wishlists?page=1'
+ last: 'http://localhost:3000/api/v2/storefront/wishlists?page=1'
+ first: 'http://localhost:3000/api/v2/storefront/wishlists?page=1'
WishedItem:
description: 200 Success - Returns an array of `wished_item` objects.
content:
diff --git a/bin/sandbox.sh b/bin/sandbox.sh
index 400eb70431..9feb93135c 100755
--- a/bin/sandbox.sh
+++ b/bin/sandbox.sh
@@ -80,10 +80,6 @@ end
gem 'sassc', github: 'sass/sassc-ruby', branch: 'master'
RUBY
-cat <<RUBY >> config/environments/development.rb
-Rails.application.config.hosts.clear
-RUBY
-
touch config/initializers/bullet.rb
cat <<RUBY >> config/initializers/bullet.rb
diff --git a/cli/LICENSE b/cli/LICENSE
index 3b57c94ed0..df99062fca 100644
--- a/cli/LICENSE
+++ b/cli/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2015, Spree Commerce, Inc. and other contributors
+Copyright (c) 2007-2024, Spree Commerce, Inc., Spark Solutuons Sp. z o.o. and other contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
diff --git a/core/LICENSE b/core/LICENSE
index 3b57c94ed0..df99062fca 100644
--- a/core/LICENSE
+++ b/core/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2015, Spree Commerce, Inc. and other contributors
+Copyright (c) 2007-2024, Spree Commerce, Inc., Spark Solutuons Sp. z o.o. and other contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
diff --git a/core/config/routes.rb b/core/config/routes.rb
index 29b2357c77..ff404b3d0e 100644
--- a/core/config/routes.rb
+++ b/core/config/routes.rb
@@ -2,9 +2,9 @@
# see: https://github.com/rails/rails/issues/34872
Rails.application.routes.draw do
direct :cdn_image do |model, options|
- host = Spree.cdn_host || Rails.application.routes.default_url_options[:host] || 'localhost'
- port = Rails.application.routes.default_url_options[:port]
- port ||= 3000 if Rails.env.development?
+ options[:host] = Spree.cdn_host if Spree.cdn_host.present?
+ options[:host] ||= Rails.application.routes.default_url_options[:host]
+ options[:host] ||= 'localhost' if Rails.env.development?
if model.blob.service_name == 'cloudinary' && defined?(Cloudinary)
if model.class.method_defined?(:has_mvariation)
@@ -21,7 +21,7 @@ Rails.application.routes.draw do
:rails_service_blob_proxy,
model.signed_id,
model.filename,
- options.merge(host: host, port: port)
+ options
)
else
signed_blob_id = model.blob.signed_id
@@ -33,7 +33,7 @@ Rails.application.routes.draw do
signed_blob_id,
variation_key,
filename,
- options.merge(host: host, port: port)
+ options
)
end
end
diff --git a/core/spec/lib/spree/money_spec.rb b/core/spec/lib/spree/money_spec.rb
index 0063150055..00b2a507f1 100644
--- a/core/spec/lib/spree/money_spec.rb
+++ b/core/spec/lib/spree/money_spec.rb
@@ -101,14 +101,12 @@ describe Spree::Money do
# rubocop:disable Style/AsciiComments
it 'formats as HTML if asked (nicely) to' do
money = described_class.new(10, format: '%n %u')
- # The HTML'ified version of "10.00 €"
- expect(money.to_html).to eq('10.00&nbsp;&#x20AC;')
+ expect(money.to_html).to eq('10.00&nbsp;€')
end
it 'formats as HTML with currency' do
money = described_class.new(10, format: '%n %u', with_currency: true)
- # The HTML'ified version of "10.00 €"
- expect(money.to_html).to eq('10.00&nbsp;&#x20AC; EUR')
+ expect(money.to_html).to eq('10.00&nbsp;€ EUR')
end
# rubocop:enable Style/AsciiComments
end
diff --git a/sample/db/samples/stores.rb b/sample/db/samples/stores.rb
index e459689a65..533e7dd343 100644
--- a/sample/db/samples/stores.rb
+++ b/sample/db/samples/stores.rb
@@ -3,12 +3,12 @@ default_store.checkout_zone = Spree::Zone.find_by(name: 'North America')
default_store.default_country = Spree::Country.find_by(iso: 'US')
default_store.supported_currencies = 'CAD,USD'
default_store.supported_locales = 'en,fr'
-default_store.url = Rails.env.development? ? 'localhost:4000' : 'demo.spreecommerce.org'
+default_store.url = Rails.env.development? ? 'localhost:3000' : 'demo.spreecommerce.org'
default_store.save!
eu_store = Spree::Store.find_or_initialize_by(code: 'eustore')
eu_store.name = 'EU Store'
-eu_store.url = Rails.env.development? ? 'eu.lvh.me:4000' : 'demo-eu.spreecommerce.org'
+eu_store.url = Rails.env.development? ? 'eu.lvh.me:3000' : 'demo-eu.spreecommerce.org'
eu_store.mail_from_address = '[email protected]'
eu_store.default_currency = 'EUR'
eu_store.default_locale = 'de'
@@ -19,7 +19,7 @@ eu_store.save!
uk_store = Spree::Store.find_or_initialize_by(code: 'ukstore')
uk_store.name = 'UK Store'
-uk_store.url = Rails.env.development? ? 'uk.lvh.me:4000' : 'demo-uk.spreecommerce.org'
+uk_store.url = Rails.env.development? ? 'uk.lvh.me:3000' : 'demo-uk.spreecommerce.org'
uk_store.mail_from_address = '[email protected]'
uk_store.default_currency = 'GBP'
uk_store.default_locale = 'en'