Localhost keeps redirecting to site url (lando + bedrock + sage)

After using Valet + Bedrock/Sage + Capistrano the last few years I recently ditched valet and started using Lando for all local dev after the great guide by @knowler and I 99% love it! It works fantastic 80% of the time but i’m having a few tiny issues that seem to crop up after normal usage and wanted to see if anyone else has run across them:

#1 localhost:3000 automatically redirects to the Site URL which never allows the site to be viewed on at the localhost URL rendering watch useless. It doesn’t happen immediately upon creating a fresh lando + bedrock + sage install but instead just seems to happen at some point. I’m not positive but I think it may start happening after running lando rebuild(again not certain of this)

I’ve tried the following with no avail:

  • Changing the port number in .lando.yml and config.json
  • Clearing both the browser and DNS cache (along with disabling dnscrypt)
  • Running lando stop and lando poweroff then lando start
  • Restarting docker and running lando rebuild
  • Installing/Activating a fresh sage 9.0.9

I end up resorting to running lando yarn build after each save then manually refreshing the page as the only thing that seemed to fix it is rather cumbersome… running lando destroy (after backing up the database) removing vendor and node_modules directories and reinstalling. :weary:

Anyways, here’s my .lando.yml:

name: justiceforkevinbrame
recipe: wordpress
proxy:
  theme:
    - localhost:8080
  phpmyadmin:
    - phpmyadmin.justiceforkevinbrame.lndo.site
  mailhog:
    - mail.justiceforkevinbrame.lndo.site

config:
  php: '7.2'
  via: nginx
  webroot: web
  database: mariadb
  xdebug: true

services:
  appserver:
    type: php:7.2

  database:
    type: mariadb

  theme:
    type: node
    overrides:
      services:
        ports:
          - 8080:8080

  phpmyadmin:
    type: phpmyadmin

  mailhog:
    type: mailhog
    hogfrom:
      - appserver

tooling:
  yarn:
    service: theme

  composer:
    service: appserver
    description: Run composer commands
    cmd: composer --ansi

  php:
    service: appserver

  mysql:
    user: root
    service: database
    description: Drop into a MySQL shell

  sendmail:
    service: appserver
    cmd: /usr/local/bin/mhsendmail

  alert:
      service: appserver
      cmd: php /app/mail.php

#2 Consistently in Sage 9.0.7, while runing webpack watch, the CSS stops updating in the browser once you try to save any change that results in a stylelint error …even after correcting the error. Webpack says it has recompiled but the browser wont show updated styles until stopping and restarting webpack watch.

Any thoughts or ideas appreciated.

I know this thread has no traction yet, but I wanted to update for any casual browsers. I went ahead and nuked everything and upgraded my lando from 3.0.0-RC.1 to RC.12 and both of my previous issues are now working. I’ll continue to monitor and see if #1 happens again and try to determine a root cause.

Also, for any other casual browsers see this thread Issue starting Lando with Bedrock if you’re encountering issues with version of lando 3.0.0-RC2 and greater.

I’ll update the guide with the changes from the other thread, but after that I’ll probably hold off with any updates until Lando 3 is officially released. Personally, I’ve stopped using Lando and have shifted to use Valet for Nginx/PHP + Docker for MySQL for quick changes or testing — Trellis/Vagrant is still my main development work environment since I want dev-prod parity. Valet — and anything local for that matter — is hard to beat speed-wise since file syncing isn’t necessary. Then I usually like to put MySQL in a Docker container since I don’t like running it locally or in a shared environment. I would love to use Lando again in the future, but the speed of file syncing in Docker makes it difficult for development when there is lots of file change (i.e. installing node_modules).

1 Like

Thanks for sharing insights on your workflow! I do miss the speed of valet but didn’t like the limiting factors of having to share the same versions of php/mysql/etc across sites. For example now i’m working on updating a site pro bono that was on WP 3.0 so having control of the php version was helpful!!

I never used vagrant in the past due to previously working on a machine with very limited resources and it just seemed like too much overhead (even though my machine now is plenty capable). I never officially used trellis either aside from some local testing. Correct me if i’m wrong but in order to use trellis you have to be deploying to an unprovisioned droplet/instance? Most of my clients are in shared environments so i’ve been rolling with capistrano for the last few years.

Anyways, thanks again for introducing me to lando, I think i’ll be on that train for a while!

In regards to issue #1 that I described in my original post, I figured out the root cause of the redirect from localhost to the site_url and am quite puzzled on how to fix it.

So, it looks like as soon as I update the Homepage Settings to be “a static page” as opposed to “your latest posts” then localhost:3000 automatically redirects to justiceforkevinbrame.lndo.site …changing back allows me to use localhost again but at the cost of not being able to set a static page… rather annoying!

Any insights from anyone appreciated!

:beers:

Hail mary here, try reset permalinks?

This topic was automatically closed after 42 days. New replies are no longer allowed.