Skip to content

[Mentions] URL generated use cached domain instead of current request domain, breaking multi-domain setups #4226

@huoxin233

Description

@huoxin233

Current Behavior

When using multiple domain setup in config.php:
'url' => 'https://' . \Illuminate\Support\Arr::get($_SERVER, 'HTTP_HOST', 'flarum1.local'),
User mentions and post mentions show incorrect domain (e.g. flarum1.local instead of flarum2.local), while other URLs correctly use the current request domain (e.g. avatar links). You can also see that PostPreview uses relative path which I think can be a fix of this issue.
Image

Steps to Reproduce

  1. Setup multiple domain in config.php 'url' => 'https://' . \Illuminate\Support\Arr::get($_SERVER, 'HTTP_HOST', 'your.domain'),
  2. Access the website using your first domain (e.g. flarum1.local) and make a post that mention a user or post
  3. Access the post using another domain that you had setup (e.g. flarum2.local)
  4. The link is still showing the previous domain
  5. If you clear cache and refresh, then the link will change to the second domain (flarum2.local)

Expected Behavior

URLs generated by Mentions should respect the current request domain context

Screenshots

No response

Environment

  • Flarum version: 1.8.10
  • Webserver: nginx
  • PHP version: 8.2.7
  • Mentions extension version: 1.8.5

Output of php flarum info

Flarum core: 1.8.10
PHP version: 8.2.7
MySQL version: 8.0.35
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, iconv, imap, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, soap, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlrpc, xmlwriter, xsl, zip, Zend OPcache
+--------------------------------+------------+------------------------------------------+
| Flarum Extensions | | |
+--------------------------------+------------+------------------------------------------+
| ID | Version | Commit |
+--------------------------------+------------+------------------------------------------+
| flarum-flags | v1.8.2 | |
| flarum-likes | v1.8.1 | |
| flarum-approval | v1.8.2 | |
| antoinefr-money | v1.3.1 | |
| flarum-tags | v1.8.4 | |
| flarum-subscriptions | v1.8.1 | |
| flarum-suspend | v1.8.4 | |
| ziiven-daily-check-in | v0.3.7 | |
| yannisme-oxotheme | 2.1.8 | |
| ramesh-dada-bbcode-alerts | 6.21 | |
| pipecraft-id-slug | v1.1.0 | |
| ianm-synopsis | 1.3.7 | |
| huoxin-auto-follow-discussion | dev-master | de044890b0d0328bae39407e518e8e1bdca5bab5 |
| glowingblue-null-driver | 1.0.0 | |
| fof-links | 1.3.0 | |
| fof-linguist | 1.1.5 | |
| fof-byobu | 1.4.1 | |
| fof-best-answer | 1.6.4 | |
| flarum-sticky | v1.8.2 | |
| flarum-statistics | v1.8.1 | |
| flarum-nicknames | v1.8.2 | |
| flarum-mentions | v1.8.5 | |
| flarum-markdown | v1.8.1 | |
| flarum-lock | v1.8.2 | |
| flarum-lang-english | v1.8.0 | |
| flarum-lang-chinese-simplified | v1.6.0 | |
| flarum-extension-manager | v1.0.7 | |
| flarum-emoji | v1.8.1 | |
| flarum-bbcode | v1.8.0 | |
| datlechin-usercard-uid | v0.1.1 | |
| clarkwinkelmann-status | 1.0.0 | |
| clarkwinkelmann-circle-groups | 1.0.1 | |
| askvortsov-moderator-warnings | v0.6.3 | |
| afrux-forum-widgets-core | v0.1.7 | |
+--------------------------------+------------+------------------------------------------+

Possible Solution

Use relative path instead of abusolute url for mentions
('/u/admin' instead of 'https://my.domain/u/admin')

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions