Yes, I finally realized my mistake in understanding the work of the cross-platform application and realized that the option I chose was irrational and meaningless. Many thanks for the clarification.
Latest posts made by frt
-
RE: api via express
-
RE: api via express
Yes, I very poorly and incorrectly put it.
What I want is the proxying of api requests to a separate express server, which will process them and return the data.
In the nuxt’s /nuxt.config,js you can specify an api request handler as a parameter:module.exports = { serverMiddleware: [ // Will register file from project api directory to handle /api/* requires { path: '/api', handler: '~/api/index.js' }, ], }
in api/index.js:
const express = require('express'); const bodyParser = require('body-parser'); const app = express(); app.use(bodyParser.json()); // Register API routes const module1 = require('./routes/module1'); const module2 = require('./routes/module2'); // Import API Routes app.use('/user', module1); app.use('/item', module2); // Export the server middleware module.exports = { path: '/api', handler: app, };
Yes, in quasar, I achieved the same result by importing modules into the srs-ssr/extension.js:
const module1 = require('../api/routes/module1'); const module2 = require('../api/routes/module2'); app.use('/api/user', module1); app.use('/api/item', module2);
It’s works in dev mode. But after build, quasar generate dist folder and required paths to modules become invalid. In addition, this solution is only for the SSR mode and is not cross-platform, which, it seems to me, is stupid and looks like a crutch.
I hope this time I described my problem in more detail in understanding how to solve this, as it initially seemed to me, trivial task.
Thanks for the help -
api via express
how to use quasar in parallel with Express in way it used in Nuxt (https://ru.nuxtjs.org/api/nuxt-render/ or as serverMiddleware in nuxt.config.js) ?