Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app-vite): Fix SSR publicPath handling #12972

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions app-vite/lib/modes/ssr/ssr-devserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class SsrDevServer extends AppDevserver {
#viteServer
#htmlWatcher
#webserverWatcher
/**
* @type {{
* port: number;
* publicPath: string;
* resolveUrlPath: import('../../../types').SsrMiddlewareResolve['urlPath'];
* render: (ssrContext: import('../../../types').QSsrContext) => Promise<string>;
* }}
*/
#appOptions = {}

// also update pwa-devserver.js when changing here
Expand Down Expand Up @@ -296,12 +304,10 @@ class SsrDevServer extends AppDevserver {
})
})

await injectMiddlewares(middlewareParams)
rstoenescu marked this conversation as resolved.
Show resolved Hide resolved

const { publicPath } = this.#appOptions

publicPath.length !== '/' && app.use((req, res, next) => {
const pathname = new URL(req.url).pathname || '/'
publicPath !== '/' && app.use((req, res, next) => {
const pathname = new URL(req.url, `http://${request.headers.host}`).pathname || '/'

if (pathname.startsWith(publicPath) === true) {
next()
Expand Down Expand Up @@ -341,6 +347,8 @@ class SsrDevServer extends AppDevserver {
next()
})

await injectMiddlewares(middlewareParams)

const isReady = () => Promise.resolve()

const listenResult = await listen({
Expand Down