error using direct path url vs ok when navigating by mouse

On one of my sites (in production) if I navigate to https:///set_locale/ko the browser doesn’t load the page but if I’m on the site and I click the link for that url it works fine I was notified about the error by GSC

You haven’t told us what you see in the rails log when you do that. I am sure you will have looked there before asking.

Not that you have actually asked a question, just told us that you have this interesting occurrence.

Also you haven’t told us what is shown in the browser console when it happens.

Colin

Both browser console and log say 500 internal server error

Well that is why it doesn’t show the page then.

Colin

It’s not a page, it’s a link to set_locale path It only changes the locale Does that help

Is the link doing a GET request or a POST request? make sure your route matches GET requests too.

  • <%= link_to "한국어", set_locale_path(locale: "ko") %>

    get ‘set_locale/:locale’ => ‘world#set_locale’, as: ‘set_locale’

    def set_locale
    I18n.locale = params[:locale] || “zh-TW”
    respond_to do |format|
    format.html { redirect_to request.referrer }
    end
    end

  • You are using redirect_to request.referrer and referrer is nil if you enter the url by hand.

    Use redirect_back fallback: root_path instead.

    Sorry, redirect_back fallback_location: root_path.

    Cool Thanks Can you tell me how do I get google to crawl my site in every locale? Just the way I’m doing it now? If not that would mean I should disallow those set_locale links in robots.txt?