-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
379 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import compression from 'compression'; | ||
import { ssrMiddleware } from 'quasar/wrappers'; | ||
|
||
export default ssrMiddleware(({ app }) => { | ||
app.use( | ||
compression({ threshold: 0 }), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { RenderError } from '@quasar/app-webpack'; | ||
import { ssrMiddleware } from 'quasar/wrappers'; | ||
|
||
// This middleware should execute as last one | ||
// since it captures everything and tries to | ||
// render the page with Vue | ||
|
||
export default ssrMiddleware(({ app, resolve, render, serve }) => { | ||
// we capture any other Express route and hand it | ||
// over to Vue and Vue Router to render our page | ||
app.get(resolve.urlPath('*'), (req, res) => { | ||
res.setHeader('Content-Type', 'text/html'); | ||
|
||
render(/* the ssrContext: */ { req, res }) | ||
.then((html) => { | ||
// now let's send the rendered html to the client | ||
res.send(html); | ||
}) | ||
.catch((err: RenderError) => { | ||
// oops, we had an error while rendering the page | ||
|
||
// we were told to redirect to another URL | ||
if (err.url) { | ||
if (err.code) { | ||
res.redirect(err.code, err.url); | ||
} else { | ||
res.redirect(err.url); | ||
} | ||
} else if (err.code === 404) { | ||
// hmm, Vue Router could not find the requested route | ||
|
||
// Should reach here only if no "catch-all" route | ||
// is defined in /src/routes | ||
res.status(404).send('404 | Page Not Found'); | ||
} else if (process.env.DEV) { | ||
// well, we treat any other code as error; | ||
// if we're in dev mode, then we can use Quasar CLI | ||
// to display a nice error page that contains the stack | ||
// and other useful information | ||
|
||
// serve.error is available on dev only | ||
serve.error({ err, req, res }); | ||
} else { | ||
// we're in production, so we should have another method | ||
// to display something to the client when we encounter an error | ||
// (for security reasons, it's not ok to display the same wealth | ||
// of information as we do in development) | ||
|
||
// Render Error Page on production or | ||
// create a route (/src/routes) for an error page and redirect to it | ||
res.status(500).send('500 | Internal Server Error'); | ||
// console.error(err.stack) | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Start the SSR server or export your handler for serverless use | ||
* or export whatever else fits your needs. | ||
* | ||
* https://v2.quasar.dev/quasar-cli/developing-ssr/ssr-production-export | ||
* | ||
* This file is used ONLY on production. | ||
*/ | ||
|
||
import { ssrProductionExport } from 'quasar/wrappers'; | ||
|
||
export default ssrProductionExport(async ({ ssrHandler }: { ssrHandler: unknown }) => ({ onRequest: ssrHandler })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable */ | ||
// THIS FEATURE-FLAG FILE IS AUTOGENERATED, | ||
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING | ||
import "quasar/dist/types/feature-flag"; | ||
|
||
declare module "quasar/dist/types/feature-flag" { | ||
interface QuasarFeatureFlags { | ||
ssr: true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { boot } from 'quasar/wrappers'; | ||
import env from 'src/env'; | ||
|
||
export default boot(async({ ssrContext }) => { | ||
if (!ssrContext) { | ||
return; | ||
} | ||
|
||
await import('localstorage-polyfill'); | ||
await import('isomorphic-fetch'); | ||
|
||
Object.assign(process.env, env); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.