N
Nuxt8mo ago
Wicker

Nuxt proxy console log url

Hello, i''m using nuxt-proxy module to proxy some urls from my main app https://www.npmjs.com/package/nuxt-proxy I did some changes to the nuxt config app.baseURL i also have i18n installed and changed the stragety of it from "prefix" to "no_prefix" ( Example of changes below )
// Old baseUrl
app: {
baseURL: "/apple/iphone/"
}


// New baseURL

app:{
baseURL: "/apple/"
}
// Old baseUrl
app: {
baseURL: "/apple/iphone/"
}


// New baseURL

app:{
baseURL: "/apple/"
}
The old pages folder was
my-app/
├─ pages/
│ ├─ index.vue
│ ├─ twelve.vue
│ ├─ thirteen.vue
my-app/
├─ pages/
│ ├─ index.vue
│ ├─ twelve.vue
│ ├─ thirteen.vue
And now
my-app/
├─ pages/
│ ├─ [product]/
│ │ ├─ [model]/
│ │ ├─ [lang]/
│ │ ├─ index.vue
my-app/
├─ pages/
│ ├─ [product]/
│ │ ├─ [model]/
│ │ ├─ [lang]/
│ │ ├─ index.vue
So basically the request comes from the same url localhost:3000/apple/thirteen/en/auth/secretStuffHere but for some reason i seem to get back an html response from my service instead of a json ( saddly i dont have access to the logs of the service which would make my life easier) These are my proxy options
proxy: {
options: [
{
target: "https://myservice.io",
changeOrigin: true,
pathRewrite: {
"^/auth/": "/auth/",
},
pathFilter: ["/auth/"],
on: {
proxyReq: (proxyReq, req, res) => {
console.log("proxyReq", proxyReq);
console.log("proxyReq", req);
console.log("proxyReq", res);
/* handle proxyReq */
},
proxyRes: (proxyRes, req, res) => {
console.log("proxyRes", proxyRes);
console.log("proxyRes", req);
console.log("proxyRes", res);
},
error: (err, req, res) => {
console.log("err", err);
console.log("err", req);
console.log("err", res);
},
},
proxy: {
options: [
{
target: "https://myservice.io",
changeOrigin: true,
pathRewrite: {
"^/auth/": "/auth/",
},
pathFilter: ["/auth/"],
on: {
proxyReq: (proxyReq, req, res) => {
console.log("proxyReq", proxyReq);
console.log("proxyReq", req);
console.log("proxyReq", res);
/* handle proxyReq */
},
proxyRes: (proxyRes, req, res) => {
console.log("proxyRes", proxyRes);
console.log("proxyRes", req);
console.log("proxyRes", res);
},
error: (err, req, res) => {
console.log("err", err);
console.log("err", req);
console.log("err", res);
},
},
Is it possible to have any kind of console.log inside of the proxy to see which url is being proxied to ? I tried this as mentioned in the docs but it seems to have no effect https://github.com/chimurai/http-proxy-middleware?tab=readme-ov-file#http-proxy-events
npm
nuxt-proxy
Http-proxy middleware for Nuxt 3.. Latest version: 0.4.1, last published: a year ago. Start using nuxt-proxy in your project by running npm i nuxt-proxy. There are 2 other projects in the npm registry using nuxt-proxy.
GitHub
GitHub - chimurai/http-proxy-middleware: :zap: The one-liner node.j...
:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more - chimurai/http-proxy-middleware
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server