@@ -95,13 +95,22 @@ export default defineNuxtModule<NuxtStoriesOptions>({
9595 nuxt . options . pages = true
9696
9797 const routeBasePath = joinURL ( '/' , options . route ?. path || '' )
98- const frameBasePath = routeBasePath === '/' ? '/-frame' : routeBasePath + '-frame'
98+ // NUXT_STORIES_FRAME_BASE_PATH lets the CI build override where the frame lives.
99+ // In the two-pass GitHub Actions workflow the shell is built with e.g.
100+ // NUXT_STORIES_FRAME_BASE_PATH=/nuxt-stories-frame
101+ // so its iframes point to /nuxt-stories/nuxt-stories-frame/…, while the frame is
102+ // built with NUXT_APP_BASE_URL=/nuxt-stories/nuxt-stories-frame/ and its output is
103+ // merged into the artifact under nuxt-stories-frame/. This gives the frame its own
104+ // _nuxt/ bundle (no asset collision) and a dedicated URL namespace that is clearly
105+ // distinct from the shell's /:story* catch-all routes.
106+ const frameBasePath = process . env . NUXT_STORIES_FRAME_BASE_PATH
107+ || ( routeBasePath === '/' ? '/-frame' : routeBasePath + '-frame' )
99108
100109 // In a two-pass static build (GitHub Actions) the frame is generated with
101- // NUXT_APP_BASE_URL=/base/- frame/ so the iframe-facing /-frame/* path is already
102- // encoded in the base URL. Routes must therefore live at / (not /-frame/*) so
103- // that the generated files don't get an extra /-frame/ prefix that would make
104- // them double-nested after the merge step.
110+ // NUXT_APP_BASE_URL=/nuxt-stories/< frame-base> / so that base path is already
111+ // encoded in the app base URL. Routes must therefore live at / (not at the
112+ // frame base path) so that the generated files land directly in .output/public/
113+ // and do not get double-prefixed after the merge step.
105114 const staticFrameMode = mode === 'frame' && ! nuxt . options . dev
106115 const effectiveFrameBasePath = staticFrameMode ? '/' : frameBasePath
107116
@@ -131,9 +140,9 @@ export default defineNuxtModule<NuxtStoriesOptions>({
131140 // Disable link-crawling for both frame and shell static builds.
132141 // Frame: avoids a 404 on '/' when no root page exists.
133142 // Shell: StoriesPage is SSR'd with <iframe :src="iframeSrc">, whose computed value
134- // contains /- frame/... URLs. If crawlLinks is true, Nitro follows those links and
143+ // contains frame URLs. If crawlLinks is true, Nitro follows those links and
135144 // renders them with the shell router (/:story* catches everything), writing shell
136- // HTML into the /- frame/ subtree and clobbering the real frame output after merge.
145+ // HTML into the frame subtree and clobbering the real frame output after merge.
137146 // Explicit prerender routes (storyPaths) cover all required pages for both modes.
138147 if ( mode === 'frame' || ( mode === 'shell' && ! nuxt . options . dev ) ) {
139148 nuxt . options . nitro . prerender ||= { }
0 commit comments