vtex-io-rootpath
БесплатноБез исполняемых скриптовНе проверенApply when building VTEX IO apps that must work correctly in multi-binding stores where bindings use path prefixes (e.g. store.com/us/, store.com/br/). Covers…
от vtex★ 47 звёзд на GitHubОб этом скилле
VTEX IO rootPath for multi-binding stores
When this skill applies
Use this skill when building VTEX IO apps that must work in stores with multi-binding configurations—typically cross-border stores where multiple bindings share a single domain with path prefixes (e.g. store.com/us/, store.com/br/, store.com/mx/).
- Your app generates URLs (links, redirects, API endpoints, canonical URLs) that must include the binding's path prefix
- Your app loads assets (images, scripts, stylesheets) that break when the store uses a sub-path binding
- Your backend routes need to construct URLs for sitemaps, canonical links, or cross-binding references
- You're debugging 404s or wrong links that only appear in multi-binding stores but work fine in single-binding
Do not use this skill for:
- Single-binding stores with a dedicated domain per locale (no path prefix needed)
- General IO backend patterns (use
vtex-io-service-apps) - CDN/edge caching configuration (use
vtex-io-service-paths-and-cdn)
Decision rules
- Single-domain multi-binding (e.g.
store.com/us/,store.com/br/) →rootPathis required. Every generated URL must be prefixed with the binding's root path. - Multi-domain single-binding (e.g.
store.us,store.com.br) →rootPathis typically empty or/. URLs work without prefixing, but code should still handlerootPathgracefully (use it if non-empty, skip if empty). - Backend (Node) → The platform sends the binding's path prefix in the
x-vtex-root-pathrequest header. Your app needs an early middleware (typically calledprepare) that reads this header, sanitizes it, and stores it onctx.state.rootPath. Once set up, all downstream handlers readctx.state.rootPathdirectly. The middleware must also setVary: x-vtex-root-pathso CDN caching works correctly per binding. - Frontend (React) → Use
useRuntime().rootPathfromvtex.render-runtimeto get the current binding's path prefix in components. - Always prefix, never hardcode — Never hardcode a path prefix like
/us/. Always use the runtime-providedrootPathso the same code works across all bindings.
Hard constraints
Constraint: Always use rootPath when constructing URLs in multi-binding stores
Every URL your app generates—links, redirects, API endpoints, canonical URLs, sitemap entries—must include the rootPath prefix when the store uses path-based bindings.
Why this matters — Without rootPath, a link to /my-account/orders in the /br/ binding points to the wrong binding (or 404s). Sitemaps with unprefixed URLs break SEO by pointing search engines to the wrong locale. Redirects without the prefix send users to the default binding instead of their current one.
Detection — URLs constructed as string literals (e.g. /${slug}) without prepending rootPath. Or navigate() calls that omit the rootPath prefix.
Correct — Prepend rootPath (parsed by prepare middleware) to all generated paths.
// Backend: use ctx.state.rootPath (parsed by prepare middleware)
const { rootPath, forwardedHost } = ctx.state;
const canonicalUrl = `https://${forwardedHost}${rootPath}/product/${slug}`;
const sitemapEntry = `${rootPath}/${categoryPath}`;
// Frontend: use runtime hook
import { useRuntime } from "vtex.render-runtime";
const MyLink = ({ slug }: { slug: string }) => {
const { rootPath } = useRuntime();
return <a href={`${rootPath}/product/${slug}`}>View product</a>;
};
Wrong — Hardcoded paths without rootPath.
// Backend: missing rootPath — breaks in multi-binding
const canonicalUrl = `https://${host}/product/${slug}`
// Frontend: hardcoded path
const MyLink = ({ slug }: { slug: string }) => {
return <a href={`/product/${slug}`}>View product</a>
}
Constraint: Sanitize rootPath to avoid double slashes
When rootPath is "/" (single-binding or default binding), using it directly produces double slashes in URLs (e.g. //product/shoes). Normalize: if rootPath === "/", treat it as "".
Why this matters — Double slashes in URLs cause redirect loops, broken canonical URLs, and SEO penalties. Some CDN layers treat //path differently from /path.
Detection — URL construction that concatenates rootPath + "/" + path without checking for rootPath === "/".
Correct
// In the prepare middleware, sanitize before storing on state:
let rootPath = ctx.get("x-vtex-root-path");
if (rootPath && !rootPath.startsWith("/")) {
rootPath = `/${rootPath}`;
}
if (rootPath === "/") {
rootPath = "";
}
ctx.state.rootPath = rootPath;
// Downstream: ctx.state.rootPath is already sanitized
const { rootPath } = ctx.state;
const url = `${rootPath}/${path}`;
Wrong
const rootPath = ctx.get("x-vtex-root-path") || "/";
const url = `${rootPath}/${path}`; // Produces "//path" for default binding
Preferred pattern
State interface
Установить vtex-io-rootpath в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл vtex-io-rootpath?
Apply when building VTEX IO apps that must work correctly in multi-binding stores where bindings use path prefixes (e.g. store.com/us/, store.com/br/). Covers rootPath extraction from x-vtex-root-path header, useRuntime().rootPath in React, URL construction in backends, link generation, asset paths, and API route considerations. Use when the app breaks or produces wrong URLs in cross-border or multi-binding setups.
Как установить скилл vtex-io-rootpath?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл vtex-io-rootpath запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic