• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

476
Views
NextJS websocket proxy(?) to server through docker DNS

I have an app of NextJS frontend server and a backend server(irrelevant in this question), each defined and deployed as docker-compose service.

Since the hostname of the backend server is dynamic by docker DNS, I would have to refer to it by its service name on NextJS server, which resolves it on runtime. I use NextJS's _middleware.ts, which is essentially a convenient way to define a generic API Route as far as I can tell.

This works well for HTTP requests, but for the WebSocket request that initiates the handshake, the WebSocket class expects ws://*** format for the URL argument, which does not go through the NextJS's API Route obviously since it doesn't start with /api.

So it's looking like I:

  • have to somehow resolve the DNS hostname
  • have to use ws:// format

, and it seems these can't be achieved at the same time for NextJS. Am I missing something?

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error