spree / spree

An open source eCommerce platform giving you full control and customizability. Modular and API-first. Build any eCommerce solution that your business requires. Developed by @vendo-dev
https://spreecommerce.org
Other
13.07k stars 4.95k forks source link

Spree does not prefix URLs with relative_url_root #10052

Open DianaLaa opened 4 years ago

DianaLaa commented 4 years ago

We want to deploy spree to www.example.com/myshop/ We can reach the homepage, but none of the links we click work.

Context

Whenever we click a link, e.g. 'shop now' link, we are redirected to www.example.com/products instead of www.example.com/myshop/products. Whenever we go to www.example.com/myshop/admin, we get redirected to www.example.com/login myshop path prefix gets lost

Expected Behavior

Spree generates URLs prefixed with /myshop/ in all its links and buttons.

Actual Behavior

Spree does not know it's deployed in a subfolder and so generates links like /products instead of /myshop/products.

Possible Fix

Spree should adhere to config.relative_url_root and config.action_controller.relative_url_root or we should be able to set a prefix that Spree adheres to. We've searched the docs

Steps to Reproduce

  1. Used https://www.cloudbooklet.com/install-spree-commerce-on-google-cloud-with-ubuntu-18-04-passenger-and-nginx/ to set up nginx and Spree
  2. Used https://guides.spreecommerce.org/developer/tutorials/getting_started_tutorial.html to add missing information like additional required gems.
  3. Nginx location myshop alias to the path/to/myshop
  4. We've set config.action_controller.relative_url_root = '/myshop', we've set config.relative_url_root = '/myshop', we've followed Tim Lentse's blog post
  5. Changing the route to mount Spree::Core::Engine, at: '/myshop' (or to at: '/myshop/') crashes with `ActionController::RoutingError (No route matches [GET] "/");

Your Environment

gem 'spree', '~> 4.1'
gem 'spree_auth_devise', '~> 4.1'
gem 'spree_gateway', '~> 3.7'
heberuriegas commented 4 years ago

I confirm the same behavior

xel666 commented 4 years ago

I confirm the same. I think it's related to this https://github.com/rails/rails/issues/31476.