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

Make SSR create function async #17235

Open
yusufkandemir opened this issue May 27, 2024 · 0 comments
Open

Make SSR create function async #17235

yusufkandemir opened this issue May 27, 2024 · 0 comments

Comments

@yusufkandemir
Copy link
Member

In order to use Fastify with SSR, you would need to use a compatibility layer such as @fastify/middie or @fastify/express. That is because Quasar uses and expects connect/express-like middleware. However, the registration process for those plugins is async, which is problematic as create is expected to be synchronous.
https://github.com/fastify/middie#usage

For the dev web server, we should be able to just put an await here:

const app = middlewareParams.app = create(middlewareParams)

For the production web server, we should be able to move the create call and app interaction logic into isReady which is async.

const app = create(middlewareParams)
// fill in "app" for next calls
middlewareParams.app = app
<% if (ssr.pwa) { %>
// serve the service worker with no cache
app.use(resolveUrlPath('/<%= pwa.swFilename %>'), serveStatic('<%= pwa.swFilename %>', { maxAge: 0 }))
<% } %>
// serve "client" folder (includes the "public" folder)
app.use(resolveUrlPath('/'), serveStatic('.'))
const isReady = () => injectMiddlewares(middlewareParams)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant