We just migrated our forum to Discourse and I’m running into the following issue. When visiting: Talk Forums Disappearing? - Talk Manufacturing | 3D Hubs the user is being redirectd to https://www.3dhubs.com/talk/t-forums-disappearing/10681 which doesn’t exist.
You can see the behaviour in practice by clicking the link. The post does exist, when you for instance search for it and navigate through it that way it works fine.
My guess is Discourse is trying to be clever about the urls and is misguided by the talk/t/talk part.
Weird bug indeed. I don’t see where it redirects either, seems to be returning the correct page and then redirected by Javascript. It’s not the nginx config, it is reaching the application server.
[db5060] Started GET "/talk/t/talk-forums-disappearing/10681?safe_mode=no_custom%2Cno_plugins%2Conly_official" for 77.163.254.28 at 2018-08-07 20:19:10 +0000
[db5060] Processing by TopicsController#show as HTML
[db5060] Parameters: {"safe_mode"=>"no_custom,no_plugins,only_official", "slug"=>"talk-forums-disappearing", "topic_id"=>"10681"}
[db5060] Rendering topics/show.html.erb within layouts/application
[db5060] Rendered topics/show.html.erb within layouts/application (6.3ms)
[db5060] Rendered layouts/_head.html.erb (0.3ms)
[db5060] Rendered common/_discourse_stylesheet.html.erb (0.1ms)
[db5060] Rendered common/_special_font_face.html.erb (0.1ms)
[db5060] Rendered application/_header.html.erb (0.2ms)
[db5060] Rendered common/_discourse_javascript.html.erb (0.3ms)
[db5060] Completed 200 OK in 124ms (Views: 9.0ms | ActiveRecord: 26.0ms)
[db5060] Started GET "/talk/404-body?_=1533673157932" for 77.163.254.28 at 2018-08-07 20:19:12 +0000
[db5060] Processing by ExceptionsController#not_found_body as HTML
[db5060] Parameters: {"_"=>"1533673157932"}
[db5060] Rendering exceptions/not_found.html.erb
[db5060] Rendered exceptions/not_found.html.erb (15.3ms)
[db5060] Rendering html template
[db5060] Rendered html template (0.0ms)
[db5060] Completed 200 OK in 52ms (Views: 0.3ms | ActiveRecord: 11.6ms)
I agree, it might be better to restructure the code to not require this functionality at all but it does make the function do what it is supposed to do:
/**
Returns the current `location.pathname` without rootURL
*/
Instead of just replacing every occurrence of Discourse.BaseUri with an empty string my version only drops the baseUri when it exists on the start of the url. The only case that this will break is when you decide to use any of the starts of system paths (/u, /t, /admin, etc) as your BaseUri. This will break your site, but not more then before.
I pushed a fix that looks only at the beginning of the path which avoids this problem. Unless you use /t, /u, or something like that, but that would be a terrible idea for many reasons.