No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    SSR Server Scripts: I don't get it right

    Framework
    1
    1
    474
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gusi1994 last edited by gusi1994

      Hi guys,

      i hope someone of you can help me.
      Currently I struggle with the scripts inside the /src-ssr folder and the whole server side rendering.

      I’m not an expert in JS but I know the basics.

      My problem is that I cannot get my code inside the extension.js to work properly. Multiple problems appear:

      1. I already tried to pass the express object via a parameter inside the extendApp() function. Like this:
      // /src-ssr/index.js
      extension.extendApp({app, express});
      
      // /src-ssr/extension.js
      module.exports.extendApp = function ({app, express}) {
      

      My Intention behind this is to use the Router from the express object to learn more about express and the possibility to return json data needed inside my vue app (this RESTful api thing)
      2. Even a simple console.log() doesn’t get executed on a rebuild. I need to rerun the quasar dev -m ssr command to get some output.

      I think these issues are more or less something I misunderstood.

      One last question:

      • Is it possible to change the setup of quasar to actually use the /src-ssr/index.js in dev mode?

      Let me know if you need further code examples.
      Thanks in advance

      EDIT:
      Ok I figured out my 1. problem. Nevertheless are there new problems like a type error

      TypeError: app.Router is not a function

      I get this only when I stop the dev server. And this is the corresponding code:
      let router = app.Router();
      Even the express docs say that the function is there, also in the installed node_modules folder is the function.

       var proto = module.exports = function(options) {
        var opts = options || {};
      
        function router(req, res, next) {
          router.handle(req, res, next);
        }
      
        // mixin Router class functions
        setPrototypeOf(router, proto)
      
        router.params = {};
        router._params = [];
        router.caseSensitive = opts.caseSensitive;
        router.mergeParams = opts.mergeParams;
        router.strict = opts.strict;
        router.stack = [];
      
        return router;
      };
      
      1 Reply Last reply Reply Quote 1
      • First post
        Last post