Skip to content

Commit 994418d

Browse files
committed
Custom asset URL cleanup
1 parent 7fa4a50 commit 994418d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docs/cloud/assets.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,17 @@ The Cloud extension will construct predictable production URLs for _existing_ as
146146
You can configure a custom [rewrite](redirects.md#rewrites) to serve assets from additional URLs or paths.
147147
However, Craft will continue to generate canonical CDN URLs, unless you explicitly set a **Base URL** in the filesystem’s settings.
148148

149+
::: danger
150+
Misconfiguration of the **Base URL** setting can result in Craft generating incorrect or invalid asset URLs.
151+
:::
152+
149153
In most cases, this should point to an [environment variable](environments.md#variables) containing a fully-qualified URL—likely one of your configured [domains](domains.md).
150154

151155
::: warning
152156
Using a value beginning with `@web` is strongly discouraged, as its value can differ based on how the site is accessed.
153157
:::
154158

155-
To serve assets from a vanity domain like `assets.mydomain.com`, follow these steps:
159+
To serve assets from a vanity domain like `cdn.mydomain.com`, follow these steps:
156160

157161
1. Create a [subdomain](domains.md#subdomains);
158162
1. Add a rewrite to your `cloud.yaml` file:
@@ -167,5 +171,6 @@ To serve assets from a vanity domain like `assets.mydomain.com`, follow these st
167171
```
168172
1. Define a variable containing that domain in each of your environments, like `ASSET_DOMAIN_HOST`;
169173
1. Set **Base URL** in your Cloud filesystem to `$ASSET_DOMAIN_HOST/assets/`;
174+
1. Commit the resulting project config changes and [deploy](deployment.md) your environment;
170175
171-
If you are not using a **Subpath**, you can omit that from the **Base URL** setting.
176+
If you are not using a **Subpath**, omit that segment from the `pathname` and **Base URL** settings.

docs/cloud/redirects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ rewrites:
117117
destination: '{assetBaseUrl}/{matches.pathname.groups.assetPath}{request.url.search}'
118118
```
119119

120-
With this strategy, your files are still stored on (and available from) our CDN—all we’ve done is create an alias for the canonical CDN URL. _Craft continues to generate canonical URLs for assets to ensure that they resolve, independent of rewrite configuration._
120+
With this strategy, your files are still stored on (and available from) our CDN—all we’ve done is create an alias for the canonical CDN URL. Craft continues to generate canonical URLs for assets to ensure that they resolve, independent of rewrite configuration, unless you [explicitly set a custom URL](assets.md#custom-urls).
121121

122122
[Build artifacts](/knowledge-base/cloud-builds) (including static files from your web root) can also be proxied:
123123

0 commit comments

Comments
 (0)