wobsoriano / nuxt-proxy

Http-proxy middleware for Nuxt 3.
MIT License
92 stars 9 forks source link

500 error for ssr request, #27

Open hesamJafarzadeh opened 1 year ago

hesamJafarzadeh commented 1 year ago

hi there, i'm using nuxt-proxy and it works well on client-side, my mean is if you call a request on browser(for example submiting a form or clicking on a RouterLink) but it doesn't work if my request runs on server-side(for example when i refresh my page and i have a await useFetch() request on top of script setup) in this case it gives me error with 500 status code.

nuxt.config.ts

export default defineNuxtConfig({
  modules: ["nuxt-proxy"],
  proxy: {
    options: {
      target: "https://example.com",
      changeOrigin: true,
      pathRewrite: {
        "^/webapi": "/", 
      },
      pathFilter: ["/webapi/"],
    },
  },
....
})

i receive this error when i refresh my page and request runs on nuxt server-side http-proxy

but this request works fine on client-side How can I fix it? I want this to work on client-side and server-side