vm's avatar
Level 2

URL::to in link

In my registration confirmation email blade view I have

{{ URL::to('/verify/' . $confirmation_code) }}.<br/>

This was working just fine until now for the server version. However somehow I got it messed up. Now the email the user gets has

http://localhost/verify/HbBj3Z3hb...........

the root of the link is pointing to local host rather than my server ipaddress

so I was expecting something like

http://xxx.xxx.xxx.xxx/verify/HbBj3Z3hb.............

Where in Laravel do you set this for production environment

Thx

0 likes
5 replies
bashy's avatar

URL::to just generates a URL using the domain/IP you're using. That will change to your proper domain once it's on the server and live.

A tip for your code would be to use a URL::route()

{{ URL::route('verify.route.name', ['code' => $confirmation_code]) }}

This will check the route via the route name as and put in the code for you where needed. This is better if you change your app or the URI structure at all.

vm's avatar
Level 2

@bashy I liked your suggestion of using a named route. So I changed the blade file and pushed it up to the server. Then I registered a new user on the live website (not local). I get the email. But it still has the localhost root as indicated above.

Just to check i ssh into server created a fake route with var_dump(Request::root()) and when i went to the route it gave me http://xxx.xxx.xxx.xxx with the correct ipaddress. So I am baffled. any ideas.

Like I said it was working perfectly when I first added this functionality. But not now. The only thing I did that may or may not have caused some problem was that after a recent deployment when I looked at the logs I was seeing

Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

So I ran composer update --bloc as suggested on one of the blogs and the warning went away.

To ask in a different way wherein Laravel is '/' defined

Again any ideas how to fix this problem.

Thx

bashy's avatar

You must have localhost set somewhere (maybe hard coded). It's always worked fine for me so have a check around for it.

vm's avatar
Level 2

@bashy: I looked the whole project. found no instance where local host is hard coded except in the app.php file like so

|--------------------------------------------------------------------------
 | Application URL
 |--------------------------------------------------------------------------
 |
 | This URL is used by the console to properly generate URLs when using
 | the Artisan command line tool. You should set this to the root of
 | your application so that it is used when running Artisan tasks.
 |
 */

 'url' => 'http://localhost',

Interesting thing is when I ssh into server and change localhost to xxx.xxx.xxx.xxx everything works fine. I am thinking I will put an env variable and define it is .env file. But still like you I did not have to do this before. So if anyone has any idea why please share Thx

bashy's avatar

Yeah that url is just for Artisan commands so that the link change be changed for those.

You using 4.2.*? Can't really think of anything else

Please or to participate in this conversation.