Skip to content

Conversation

@yabo083
Copy link

@yabo083 yabo083 commented Jan 17, 2026

Description / 描述

Improve share page link generation with smart internal/external network routing.

改进分享页链接生成,支持智能内外网分流。

Changes / 更改

Smart Routing (useLink.ts) / 智能分流

  • Use location.origin for automatic network routing:

    • External access via ol.example.com → links use ol.example.com
    • Internal access via 192.168.x.x → links use 192.168.x.x
  • No configuration needed - works automatically based on how user accesses the site

  • 使用 location.origin 实现自动网络分流:

    • 外网访问 ol.example.com → 链接使用 ol.example.com
    • 内网访问 192.168.x.x → 链接使用 192.168.x.x
  • 无需配置,根据用户访问方式自动生效

Single File Share Fix / 单文件分享修复

  • Added extractSharingId() and extractPathAfterSid() helper functions

  • Correctly handle single file shares (avoid path duplication like /sd/sid/file.mp3/file.mp3)

  • Fixed URL format: /sd/{sid}/ for single file, /sd/{sid}/path/to/file for folder shares

  • 添加 extractSharingId()extractPathAfterSid() 辅助函数

  • 正确处理单文件分享(避免路径重复如 /sd/sid/file.mp3/file.mp3

  • 修复URL格式:单文件使用 /sd/{sid}/,文件夹分享使用 /sd/{sid}/path/to/file

Copy Link Improvement / 复制链接改进

  • On share pages, "Copy Link" now copies the current page URL (shareable)

  • On regular pages, still copies the direct download link

  • 分享页面上,"复制链接"现在复制当前页面URL(可分享)

  • 普通页面上,仍复制直接下载链接

Settings Loading (App.tsx) / 设置加载

  • Added initial loading state to ensure settings are loaded before rendering

  • 添加初始加载状态,确保设置在渲染前加载完成

Motivation and Context / 背景

When OpenList is deployed behind a reverse proxy, users access it via different URLs (internal IP vs external domain). Previously, share page resources always used the configured external domain, even from internal network, causing slow speeds. Now links automatically use the correct domain based on how the user accesses the site.

当 OpenList 部署在反向代理后面时,用户通过不同URL访问(内网IP vs 外网域名)。之前分享页资源总是使用配置的外网域名,即使从内网访问也是如此,导致速度慢。现在链接会根据用户访问方式自动使用正确的域名。

Configuration Recommendation / 配置建议

For optimal smart routing, leave site_url empty in config. The backend will automatically use the request's Host header for URL generation.

为了最佳智能分流效果,将配置中的 site_url 留空。后端会自动使用请求的 Host 头生成URL。

How Has This Been Tested? / 测试

  • ✅ Single file audio share - plays correctly, copy link works
  • ✅ Internal network access - uses internal IP for resources
  • ✅ External network access - uses external domain for resources
  • ✅ Download button - works from both networks
  • ✅ Image/video preview - uses correct network

Checklist / 检查清单

- Add smart internal/external network routing for share page links
- Fix single file share download links (avoid path duplication)
- Extract sharing ID correctly from share paths
- Use location.origin for automatic network routing (internal vs external)
- Copy page URL instead of download link on share pages
- Ensure settings are loaded before page rendering

This allows users to access shared resources via internal network when
accessing from LAN, and via external domain when accessing from internet,
without any manual configuration needed.
@yabo083 yabo083 changed the title feat(settings): support custom domain for share and direct links feat: improve share page link generation with smart routing Jan 18, 2026
@xrgzs xrgzs requested a review from KirCute January 18, 2026 05:33
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.

1 participant