Creating API routes and proxying for SSR #12689
-
I am developing a web app. This app requires a simple API and I am thinking creating the API within the repo. Ideally, create an express server which will handle requests from '/api/v1' and hit a mongoDB using mongoose It seems Nuxt has a great option for this particular config. There is actually a thread on the quasar forum https://forum.quasar-framework.org/topic/3509/api-via-express This thread highlights my goals well, however I am not building via Cardova / Electron. Just wanted to follow up on this thread. Does quasar offer a way to replicate this behavior using ssr? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
if i understand correctly you need a proxy to redirect to your api. if you use quasar v1 import { createProxyMiddleware } from 'http-proxy-middleware'; for quasar v2 import { createProxyMiddleware } from 'http-proxy-middleware'; |
Beta Was this translation helpful? Give feedback.
if i understand correctly you need a proxy to redirect to your api.
You can make with http-proxy-middleware
if you use quasar v1
in file src-ssr/index.js
import { createProxyMiddleware } from 'http-proxy-middleware';
...
app.use('/api', createProxyMiddleware({ target: 'http://localhost:8000', changeOrigin: true }))
for quasar v2
src-src/compression.js
import { createProxyMiddleware } from 'http-proxy-middleware';
...
app.use('/api', createProxyMiddleware({ target: 'http://localhost:8000', changeOrigin: true }));