Skip to content

defineConfig

defineConfig is a helper for creating a typed bunny.config.ts configuration file.

import { defineConfig } from "@farbenmeer/bunny";
function defineConfig(config: BunnyConfig): BunnyConfig
interface BunnyConfig {
vite?: UserConfig;
server?: ServerConfig;
}
PropertyTypeDescription
viteUserConfig (from Vite)Extend or override the Vite configuration used during development and production builds.
serverServerConfigConfigure how the Bunny server resolves the public URL of incoming requests.
interface ServerConfig {
trustForwardedHeader?: boolean;
trustHostHeader?: boolean;
host?: string;
protocol?: string;
}
PropertyTypeDefaultDescription
trustForwardedHeaderbooleanfalseTrust the X-Forwarded-Host and X-Forwarded-Proto headers when determining the request URL. Enable this when running behind a reverse proxy that sets these headers.
trustHostHeaderbooleanfalseTrust the Host header when determining the request URL. Enable this when your reverse proxy forwards the original Host header and you want it used for URL construction.
hoststringA static hostname to use when constructing the request URL. Takes precedence over header-based host detection.
protocolstringA static protocol (http or https) to use when constructing the request URL. Takes precedence over header-based protocol detection.

Create a bunny.config.ts in your project root:

import { defineConfig } from "@farbenmeer/bunny";
export default defineConfig({
vite: {
// Any Vite configuration
},
server: {
trustForwardedHeader: true, // trust X-Forwarded-Host / X-Forwarded-Proto
},
});

The config file is optional. If it does not exist, Bunny uses its defaults.

Bunny always adds vite-tsconfig-paths to the Vite plugins so TypeScript path aliases work out of the box. Your vite.plugins are merged alongside it.