Support separate asset base (CDN) vs app base in TanStack Start (Vite) #5036
Replies: 3 comments 7 replies
-
|
Hey @tannerlinsley @schiller-manuel , |
Beta Was this translation helpful? Give feedback.
-
|
NOTE: this is just an imperfect workaround. Using nitro, I'm doing this: // nitro.config.js
export default defineNitroConfig({
runtimeConfig: {
app: {
baseURL: '/',
},
},
});
// vite.config.ts
export default defineConfig(({ mode }) => {
const isProduction = mode === 'production';
return {
base: isProduction ? process.env.VITE_ASSET_URL_PREFIX : '/',
// rest of config
}
}You obviously don't need the env var, it's just how I'm doing it. My workflow uploads everything from |
Beta Was this translation helpful? Give feedback.
-
|
@schiller-manuel |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
We need the application to live at /app-base-path (e.g., https://www.example.com/app-base-path) while all built assets (JS/CSS) are served from a CDN like https://edge.example.com/asset-path. With TanStack Start today, Vite’s base config is used as a single source of truth (TSS_APP_BASE) for both routing and asset URLs, so we can’t configure a separate asset base without affecting the app base.
What we’ve tried
base: '/app-base-path'+ routerbasepath: '/app-base-path'→ routes work, but assets resolve under /app-base-path on the origin.basemakes the server/app base follow the CDN URL, which breaks routing/server paths.What we’re asking
Possible approaches (examples)
Why this helps
Is there an undocumented way to do this today? If not, would you consider adding support for a split asset base?
Beta Was this translation helpful? Give feedback.
All reactions