Skip to content

Conversation

@farnabaz
Copy link
Member

@farnabaz farnabaz commented Aug 8, 2025

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Aug 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
content-docs Ready Ready Preview Sep 1, 2025 7:53am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 8, 2025

npm i https://pkg.pr.new/@nuxt/content@3500

commit: 9463608

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 8, 2025

Deploying content with Β Cloudflare Pages Β Cloudflare Pages

Latest commit: 9463608
Status:Β βœ…Β  Deploy successful!
Preview URL: https://5c4ecc2f.content-f0q.pages.dev
Branch Preview URL: https://fix-websocker-public-url.content-f0q.pages.dev

View logs

@hendrikheil
Copy link
Contributor

Great work! I verified this works, you just have to specify watch.port and watch.publicUrl where publicUrl: wss://{domain}

@farnabaz
Copy link
Member Author

@dargmuesli I think this PR also affect/help you, but it should not break the current behavior.

// Register ws url
;(nitro.options.runtimeConfig.public.content as Record<string, unknown>).wsUrl = listener.url.replace('http', 'ws')
const publicConfig = nitro.options.runtimeConfig.public.content as Record<string, unknown>
publicConfig.wsUrl = (websocketOptions.publicURL || listener.url).replace('http', 'ws')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publicConfig.wsUrl = (websocketOptions.publicURL || process.env.publicURL || listener.url).replace('http', 'ws')

to use option --publicURL defined by the nuxt dev command.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tries this?
Public URL of websocket and Nuxt are different, since the module creates its own server for websocket, using same publicURL will cause issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s actually only the port that is different, not the public URL.

Copy link
Member Author

@farnabaz farnabaz Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s actually only the port that is different, not the public URL.

We are passing the whole url to client and we don't change the port. So sharing same url means calling to the same port.

We can do it by adding port to publicUrl in publicConfig.wsUrl = (websocketOptions.publicURL || listener.url).replace('http', 'ws') but the end result will not be same.

@maximepvrt
Copy link
Contributor

maximepvrt commented Aug 26, 2025

Laravel Valet proxies allow binding a domain to a service running on a specific port, but they don’t support handling multiple services with different ports.

Example:

monsite.test    => https://localhost:3000
monsite.test:4000 => https://localhost:4000 (not supported)

That’s why I’d rather keep using https://localhost:4000 directly for Hot Content Reload, to avoid CORS issues with websockets.

@farnabaz farnabaz merged commit fb0f022 into main Sep 1, 2025
6 checks passed
@farnabaz farnabaz deleted the fix/websocker-public-url branch September 1, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants