question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

devProxy websocket not working

See original GitHub issue

Environment

  • Operating System: Windows_NT
  • Node Version: v16.18.0
  • Nuxt Version: 3.0.0-rc.13
  • Nitro Version: 0.6.1
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: modules, experimental, css, colorMode, nitro
  • Runtime Modules: @vueuse/nuxt@9.5.0, @unocss/nuxt@0.46.3, @pinia/nuxt@0.4.3, @nuxtjs/color-mode@3.1.8
  • Build Modules: -

Reproduction

https://github.com/huuhait/github-5pp8lm

Describe the bug

The devProxy not working for websocket

Additional context

Websocket URL: wss://demo.zsmartex.com/api/v2/websocket/public Test url: https://demo.zsmartex.com/

Local proxy URL: ws://localhost:8080/api/v2/websocket/public

Logs

No response

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
danielroecommented, Nov 9, 2022

cc: @pi0

1reaction
jaydrogerscommented, Nov 10, 2022

Adding a note on this thread since I accidentally placed it on a Nuxt V2 issue:

I met with @danpastori on the phone and we went through this via screen sharing for 2+ hours.

Problem we are experiencing

  • The page will constantly refreshes in development because it’s trying to find wss://0.0.0.0:4000/ws

Attempted solutions

Our nuxt.config.ts:

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
    modules: [
        '@nuxt/content',
        '@nuxtjs/tailwindcss',
        '@pinia/nuxt',
        '@vueuse/nuxt',
    ],

    runtimeConfig: {
        public: {
            API_BASE_URL: process.env.API_BASE_URL,
            BASE_URL: process.env.BASE_URL
        }
    },

    imports: {
        dirs: ["./utils"],
    },

    content: {
        
    },

    nitro: {
        devProxy: {
            '/ws': { target: 'https://bugflow.dev.test/ws', changeOrigin: true, ws: true }
        }
    }
})

Actual results

  • Using devProxy seem to not have any affect on changing the URL
Read more comments on GitHub >

github_iconTop Results From Across the Web

Proxy websockets connection within webpack-dev-server
I know how to proxy regular HTTP requests to another backend but it's not working for websockets, presumably because the target in the...
Read more >
WebSocket Delivery Mode - Software AG Documentation
WebSocket communication through reverse proxy servers using the application layer (HTTP in this case) may work in some but not all scenarios. The...
Read more >
Server Options - Vite
When running Vite on WSL2, file system watching does not work when a file is edited by Windows applications (non-WSL2 process). This is...
Read more >
DevServer - webpack
This option allows specifying URL to web socket server (useful when you're proxying dev server and client script does not always know where...
Read more >
Websocket connection behind HTTP proxy does not work
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0. Steps to reproduce: I'm trying to use a website that uses ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found