Skip to content

fix: use current page port instead of hardcoded 4096#5949

Merged
adamdotdevin merged 1 commit intoanomalyco:devfrom
majiayu000:fix/5928-port-hardcoded
Dec 22, 2025
Merged

fix: use current page port instead of hardcoded 4096#5949
adamdotdevin merged 1 commit intoanomalyco:devfrom
majiayu000:fix/5928-port-hardcoded

Conversation

@majiayu000
Copy link
Copy Markdown
Contributor

Summary

  • Uses location.host for localhost/127.0.0.1 to preserve actual server port
  • Allows opencode --port=8080 to work correctly with web interface

Fixes #5928

Fixes anomalyco#5928

When accessing via localhost/127.0.0.1, use location.host to preserve
the actual port the server is running on, instead of hardcoding to 4096.

Co-Authored-By: Claude <[email protected]>
@adamdotdevin adamdotdevin merged commit d04a72a into anomalyco:dev Dec 22, 2025
2 checks passed
adamdotdevin added a commit that referenced this pull request Dec 22, 2025
@majiayu000 majiayu000 deleted the fix/5928-port-hardcoded branch December 22, 2025 12:01
@majiayu000
Copy link
Copy Markdown
Contributor Author

Thanks for the quick review! I noticed it was reverted - is there anything I should adjust for the fix? Happy to submit a new PR if needed.

@adamdotdevin
Copy link
Copy Markdown
Member

Thanks for the quick review! I noticed it was reverted - is there anything I should adjust for the fix? Happy to submit a new PR if needed.

Unfortunately this broke the tauri desktop app!

majiayu000 added a commit to majiayu000/opencode that referenced this pull request Dec 22, 2025
This fix addresses issue anomalyco#5928 where `opencode --port=8080` fails because
the port is hardcoded to 4096. The previous fix (anomalyco#5949) was reverted because
it broke the Tauri desktop application.

This implementation:
- Preserves the priority of `window.__OPENCODE__` check for Tauri apps
- Only adds localhost/127.0.0.1 detection as a fallback before "/"
- Uses `location.host` to dynamically get the correct port for web browsers
- Does not affect Tauri desktop app which has its own port management

Fixes anomalyco#5928

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@majiayu000
Copy link
Copy Markdown
Contributor Author

Hi @adamdotdevin , I fix this problem in #5967.

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.

opencode --port=8080 fails because port statically bound to 4096

2 participants