site
The site's public URL, of which only the origin is used, for absolute URLs in sitemap.xml, robots.txt and document.seo.
site is the site's public origin ("https://example.com", without a path). It is the origin for absolute URLs Meeko writes during the build: those in sitemap.xml, the Sitemap: line in robots.txt and, with document.seo, <link rel="canonical"> and og:url. Without site, the build uses MEEKO_PUBLIC_ORIGIN from its environment.
site is set at build time and does not change HTTP and Socket Origin checks: those still read MEEKO_PUBLIC_ORIGIN or publicOrigin from server/runtime.ts at runtime.
Usage#
// meeko.config.ts
import { defineMeekoConfig } from "@meekojs/meeko/framework";
export default defineMeekoConfig({
site: "https://example.com",
sitemap: true,
robots: true,
document: { seo: true },
});Type#
readonly site?: stringOptions#
| Value | Type | Default | Description |
|---|---|---|---|
site |
string |
Build's MEEKO_PUBLIC_ORIGIN |
An absolute http: or https: URL without a path, query, fragment or credentials. |
Result#
With site: "https://example.com":
<!-- sitemap.xml -->
<url><loc>https://example.com/docs/api</loc></url># robots.txt
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml<!-- /docs/api with document.seo -->
<link rel="canonical" href="https://example.com/docs/api">Examples#
One origin per environment#
import { defineMeekoConfig } from "@meekojs/meeko/framework";
export default defineMeekoConfig({
site: process.env.SITE_URL ?? "https://example.com",
sitemap: true,
});SITE_URL=https://staging.example.com npm run buildWithout site, using the build variable#
MEEKO_PUBLIC_ORIGIN=https://example.com npx meeko buildThe same variable later sets the origin for Origin checks in production.
Common mistakes#
A URL with a path#
export default defineMeekoConfig({ site: "https://example.com/blog" });meeko dev, meeko build, meeko check and meeko routes stop with …/meeko.config.ts: site must be an origin without path, query, fragment or credentials, such as "https://example.com". Hosting a site under a subpath is not supported.
import { defineMeekoConfig } from "@meekojs/meeko/framework";
export default defineMeekoConfig({ site: "https://example.com" });A domain without a scheme#
export default defineMeekoConfig({ site: "example.com" });…/meeko.config.ts: site must be an absolute URL such as "https://example.com".
import { defineMeekoConfig } from "@meekojs/meeko/framework";
export default defineMeekoConfig({ site: "https://example.com" });Expect site to fix Origin checks#
site: "https://example.com" and the application behind a TLS proxy, without MEEKO_PUBLIC_ORIGIN at runtimeMutations (with a session and, since 1.8, also without one) respond with 403 INVALID_ORIGIN: site is only used during the build. The origin for security checks is set at runtime.
MEEKO_PUBLIC_ORIGIN=https://example.com when starting the serverNotes#
- Build only. Changing
siterequires rebuilding; it is not read in production. - No origin. With
sitemap, or withdocument.seoandcanonicalorogUrl, and withoutsiteorMEEKO_PUBLIC_ORIGIN,meeko buildstops before compiling;robotswithoutsitemapdoes not need it.