@spree/docs 0.1.126 → 0.1.128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2276,7 +2276,8 @@ paths:
2276
2276
  bearer_auth: []
2277
2277
  description: |
2278
2278
  Associates a guest cart with the currently authenticated user.
2279
- Requires JWT authentication. The cart must not belong to another user.
2279
+ Requires JWT authentication and possession of the cart's token
2280
+ (x-spree-token) — the token authorizes claiming the cart.
2280
2281
  x-codeSamples:
2281
2282
  - lang: javascript
2282
2283
  label: Spree SDK
@@ -2302,6 +2303,12 @@ paths:
2302
2303
  required: true
2303
2304
  schema:
2304
2305
  type: string
2306
+ - name: x-spree-token
2307
+ in: header
2308
+ required: true
2309
+ description: Cart token
2310
+ schema:
2311
+ type: string
2305
2312
  - name: id
2306
2313
  in: path
2307
2314
  required: true
@@ -2497,6 +2504,16 @@ paths:
2497
2504
  message: Authentication required
2498
2505
  schema:
2499
2506
  "$ref": "#/components/schemas/ErrorResponse"
2507
+ '403':
2508
+ description: forbidden - cart token missing or does not match
2509
+ content:
2510
+ application/json:
2511
+ example:
2512
+ error:
2513
+ code: access_denied
2514
+ message: You are not authorized to access this page.
2515
+ schema:
2516
+ "$ref": "#/components/schemas/ErrorResponse"
2500
2517
  "/api/v3/store/carts/{id}/complete":
2501
2518
  post:
2502
2519
  summary: Complete cart
@@ -37,3 +37,13 @@ Now scroll down and set the settings as below:
37
37
  ![Cloudflare Cache Rule Settings](/images/developer/deployment/cloudflare_cache_rule_2.png)
38
38
 
39
39
  Finally, click on "Deploy" and you are done!
40
+
41
+ ## Dedicated CDN Host
42
+
43
+ The setup above caches on your primary domain and needs no extra configuration. If you instead serve assets and images from a separate CDN hostname (e.g. a CloudFront or Fastly distribution at `cdn.example.com` with your app as the origin), set the `CDN_HOST` environment variable:
44
+
45
+ ```bash
46
+ CDN_HOST=cdn.example.com
47
+ ```
48
+
49
+ Static asset URLs and image/attachment URLs (including those in API responses) will then use this host instead of [`RAILS_HOST`](environment_variables.md#urls-and-hosts). Host only, no protocol — URLs keep the scheme of your primary host.
@@ -62,6 +62,9 @@ services:
62
62
  SECRET_KEY_BASE: change-me-to-a-real-secret
63
63
  RAILS_FORCE_SSL: "false"
64
64
  RAILS_ASSUME_SSL: "false"
65
+ # Public host used in generated URLs (images/attachments in API
66
+ # responses, email links) — set to your domain or IP in production.
67
+ RAILS_HOST: localhost:3000
65
68
  ports:
66
69
  - "3000:3000"
67
70
  healthcheck:
@@ -80,6 +83,7 @@ services:
80
83
  DATABASE_URL: postgres://postgres@postgres:5432/spree_production
81
84
  REDIS_URL: redis://redis:6379/0
82
85
  SECRET_KEY_BASE: change-me-to-a-real-secret
86
+ RAILS_HOST: localhost:3000
83
87
  command: bundle exec sidekiq
84
88
 
85
89
  volumes:
@@ -104,6 +108,7 @@ The database is automatically created and migrated on first boot. The app is ava
104
108
  | `DATABASE_URL` | PostgreSQL connection URL | `postgres://user:pass@host:5432/spree` |
105
109
  | `REDIS_URL` | Redis URL for jobs, caching, and Action Cable | `redis://redis:6379/0` |
106
110
  | `SECRET_KEY_BASE` | Secret key for session encryption | Generate with `bin/rails secret` |
111
+ | `RAILS_HOST` | Public host used in generated URLs — image/attachment URLs in API responses, email links. Without it they fall back to the store's URL setting (`localhost` on a fresh install) | `store.example.com` |
107
112
 
108
113
  See [Environment Variables](environment_variables.md) for the full list.
109
114
 
@@ -80,7 +80,7 @@ Set the following environment variables on the **Spree backend** to enable syste
80
80
  | `SMTP_USERNAME` | — | SMTP auth username |
81
81
  | `SMTP_PASSWORD` | — | SMTP auth password |
82
82
  | `SMTP_FROM_ADDRESS` | — | Default "from" email address (e.g., `admin@mystore.com`) |
83
- | `RAILS_HOST` | `example.com` | Host used in email URLs |
83
+ | `RAILS_HOST` | `example.com` | Public host used in email links and other [generated URLs](environment_variables.md#urls-and-hosts) — image/attachment URLs use `CDN_HOST` instead when set |
84
84
 
85
85
  When `SMTP_HOST` is not set, emails are printed to the Rails log instead of being sent.
86
86
 
@@ -16,6 +16,19 @@ These variables are required to run Spree in production.
16
16
  | `REDIS_CACHE_URL` | Redis URL for caching (optional — falls back to `REDIS_URL`) | `redis://localhost:6380/0` |
17
17
  | `SECRET_KEY_BASE` | Secret key for session encryption. Generate with `bin/rails secret` | `2fad5c0b79d25e4765d3018d8c740f8c3a665f0e5c...` |
18
18
 
19
+ ## URLs and Hosts
20
+
21
+ `RAILS_HOST` is the canonical public host of your deployment. URLs Spree generates outside a request context use it — links in emails, webhook payloads, and image/attachment URLs in API responses (for the latter, `CDN_HOST` takes precedence when set).
22
+
23
+ > **WARNING:** When neither `RAILS_HOST` nor `CDN_HOST` is configured, image and attachment URLs fall back to the store's URL setting, which is `localhost` on a fresh install — API responses will contain `https://localhost/...` URLs.
24
+
25
+ | Variable | Default | Description |
26
+ | --- | --- | --- |
27
+ | `RAILS_HOST` | — | Public host, optionally with a port — e.g. `store.example.com` or `203.0.113.7:8080`. Host only, no protocol. On [Render](render.md), falls back to the platform-provided `RENDER_EXTERNAL_HOSTNAME`. |
28
+ | `CDN_HOST` | — | Optional host for serving static assets and images, e.g. a CDN distribution in front of your app. Host only, no protocol. Falls back to `RAILS_HOST`. |
29
+
30
+ Generated URLs use `https` unless both `RAILS_FORCE_SSL` and `RAILS_ASSUME_SSL` are set to `false` (see [SSL](#ssl)).
31
+
19
32
  ## Email (SMTP)
20
33
 
21
34
  > **TIP:** This configuration is used for system emails (e.g. staff invitations, report ready, export complete). Customer facing emails are handled by the [storefront via webhooks](../storefront/nextjs/customization.md#transactional-emails).
@@ -29,7 +42,8 @@ Spree works with any SMTP provider (Resend, Postmark, Mailgun, SendGrid, Amazon
29
42
  | `SMTP_USERNAME` | — | SMTP auth username |
30
43
  | `SMTP_PASSWORD` | — | SMTP auth password |
31
44
  | `SMTP_FROM_ADDRESS` | — | Default "from" email address |
32
- | `RAILS_HOST` | `example.com` | Host used in email URLs |
45
+
46
+ Links in emails use the host configured via [`RAILS_HOST`](#urls-and-hosts).
33
47
 
34
48
  ## Web Server
35
49
 
@@ -57,6 +57,8 @@ Default credentials are created during `db:seed`. Change them immediately after
57
57
 
58
58
  Render sets `DATABASE_URL`, `REDIS_URL`, and `SECRET_KEY_BASE` automatically from the blueprint. For additional configuration (SMTP, file storage, Sentry, etc.), see [Environment Variables](environment_variables.md).
59
59
 
60
+ Generated URLs (images and attachments in API responses, email links) automatically use Render's `RENDER_EXTERNAL_HOSTNAME` (`<your-app-name>.onrender.com`). When you attach a custom domain, set [`RAILS_HOST`](environment_variables.md#urls-and-hosts) to it — it takes precedence.
61
+
60
62
  ## Production Sizing
61
63
 
62
64
  The free/starter plans work for trying Spree. For production workloads, we recommend:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/docs",
3
- "version": "0.1.126",
3
+ "version": "0.1.128",
4
4
  "description": "Spree Commerce developer documentation for AI agents and local reference",
5
5
  "type": "module",
6
6
  "license": "CC-BY-4.0",