Class: Spree::Dashboard::AppController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Spree::Dashboard::AppController
- Defined in:
- app/controllers/spree/dashboard/app_controller.rb
Overview
Serves a built React Dashboard (vite build output) at /dashboard — the
single-node topology: the SPA and the Admin API share one origin, so no
CORS entries and Lax cookies. The dist directory comes from
Spree::Dashboard.dist_path (the official Docker image sets it via
SPREE_DASHBOARD_DIST_PATH); when unset, /dashboard 404s.
SPA semantics: real files are served with long-lived caching (Vite's
assets/ are content-hashed, so they're immutable); every other path
falls back to index.html with no-cache so deploys take effect on the
next navigation. No authentication — the bundle is public client code;
the SPA authenticates its API calls itself.
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/spree/dashboard/app_controller.rb', line 24 def show root = dist_root return head :not_found unless root if (file = resolve_file(root, params[:path].to_s)) response.headers['Cache-Control'] = cache_control_for(params[:path].to_s) send_file file, disposition: 'inline' elsif (index = root.join('index.html')).file? response.headers['Cache-Control'] = 'no-cache' send_file index, type: 'text/html', disposition: 'inline' else head :not_found end end |