-1

I'm basically trying to run my Laravel installation over laravel valet through Local Network sharing. I've followed the steps described on: https://laravel.com/docs/9.x/valet#sharing-sites-on-your-local-network

However, I'm still having a 404 - not found when trying to access my website over "192.168.31.166/my-app.test".

I tried both with and without HTTPS Certificate and still got the same error. I can access the website from: my-app.test but not from 127.0.0.1/my-app.test nor from 192.168.31.166/my-app.test

Here is my valet.config file (I deliberately changed my username to USERNAME as it includes my real name):

server {
    listen 80 default_server;
    #listen VALET_LOOPBACK:80; # valet loopback
    root /;
    charset utf-8;
    client_max_body_size 128M;

    location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
        internal;
        alias /;
        try_files $uri $uri/;
    }

    location / {
        rewrite ^ "/Users/USERNAME/.composer/vendor/laravel/valet/server.php" last;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log "/Users/USERNAME/.config/valet/Log/nginx-error.log";

    error_page 404 "/Users/USERNAME/.composer/vendor/laravel/valet/server.php";

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass "unix:/Users/USERNAME/.config/valet/valet.sock";
        fastcgi_index "/Users/USERNAME/.composer/vendor/laravel/valet/server.php";
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME "/Users/USERNAME/.composer/vendor/laravel/valet/server.php";
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ /\.ht {
        deny all;
    }
}

1 Answers1

0

You need to add domain and your server IP to /etc/hosts first

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
#this is your installed valvet server local IP
192.168.31.166  my-app.test 

and then you can access from another device with my-app.test domain.

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
  • This didn't work. According to Laravel Valet documentation, i should be using 192.168.31.166/my-app.test and that also returns a Valet 404 - Not Found. Which means it detects that i'm calling Laravel Valet, but doesn't serve my website. – doctibby Dec 30 '22 at 22:57
  • Yes because your website is my-app.test, not 192.168.31.166/my-app.test . Are you sure you added the IP to `/etc/hosts` on the device that want to access my-app.test ? What page shown when you access my-app.test ? – Muhammad Dyas Yaskur Dec 30 '22 at 23:26
  • I get a 404 error page from laravel valet. My website would be 192.168.31.166/my-app.test whenever i listen to port 80 and not just 127.0.0.1:80 according to documentation. Have you take a look at it? Also, yes i tried to change hosts according to your answer and it didn't work – doctibby Dec 30 '22 at 23:57