Skip to main content

AssetServerOptions

AssetServerOptions

The configuration options for the AssetServerPlugin.

Signature
interface AssetServerOptions {
route: string;
assetUploadDir: string;
assetUrlPrefix?: string | ((ctx: RequestContext, identifier: string) => string);
previewMaxWidth?: number;
previewMaxHeight?: number;
presets?: ImageTransformPreset[];
namingStrategy?: AssetNamingStrategy;
previewStrategy?: AssetPreviewStrategy;
storageStrategyFactory?: (
options: AssetServerOptions,
) => AssetStorageStrategy | Promise<AssetStorageStrategy>;
cacheHeader?: CacheConfig | string;
}

route

property
string

The route to the asset server.

assetUploadDir

property
string

The local directory to which assets will be uploaded when using the LocalAssetStorageStrategy.

assetUrlPrefix

property
string | ((ctx: RequestContext, identifier: string) => string)

The complete URL prefix of the asset files. For example, "https://demo.vendure.io/assets/". A function can also be provided to handle more complex cases, such as serving multiple domains from a single server. In this case, the function should return a string url prefix.

If not provided, the plugin will attempt to guess based off the incoming request and the configured route. However, in all but the simplest cases, this guess may not yield correct results.

previewMaxWidth

property
number
default:
1600

The max width in pixels of a generated preview image.

previewMaxHeight

property
number
default:
1600

The max height in pixels of a generated preview image.

presets

An array of additional ImageTransformPreset objects.

namingStrategy

property
default:
<a href='/reference/core-plugins/asset-server-plugin/hashed-asset-naming-strategy#hashedassetnamingstrategy'>HashedAssetNamingStrategy</a>

Defines how asset files and preview images are named before being saved.

previewStrategy

property
v1.7.0

Defines how previews are generated for a given Asset binary. By default, this uses the SharpAssetPreviewStrategy

storageStrategyFactory

property
default:
() => <a href='/reference/core-plugins/asset-server-plugin/local-asset-storage-strategy#localassetstoragestrategy'>LocalAssetStorageStrategy</a>

A function which can be used to configure an AssetStorageStrategy. This is useful e.g. if you wish to store your assets using a cloud storage provider. By default, the LocalAssetStorageStrategy is used.

cacheHeader

property
v1.9.3
CacheConfig | string
default:
'public, max-age=15552000'

Configures the Cache-Control directive for response to control caching in browsers and shared caches (e.g. Proxies, CDNs). Defaults to publicly cached for 6 months.