Closed UchennaPrudensia closed 5 years ago
The problem with local usage is with the 127.0.0.1
IPv4 and ::1
IPv6 as the script can not tell the location of that address. But this is something which should be investigated and fixed if this is an issue.
@nerg4l maybe we should allow localhost by default? I can't really think of a use case where you wouldn't want to allow it
@axlon Maybe this can be handled in a better way as stevebauman/location
already has a basic implementation.
Ah yes, because when using a development box, it isn't said that you are accessing the site from localhost.
This sounds like a good way to implement this
@UchennaPrudensia as @nerg4l said you can use the testing tools available in stevebauman/location
which this package depends on.
I think in time we will implement our own testing, but it's not a priority right now since the above is available.
Hope this helps.
@axlon thank you so much. Does this mean i have to test each ip address from different countries one after another or can i just add the different ip's in an array? and can i still do?
Route::get('/', function () {
return view('welcome');
})->allowFrom('us');
@axlon after changing the ip in the config folder, the application still runs as normal. Its not blocking. Please take a look. I followed all the steps as mention earlier.
/*
|--------------------------------------------------------------------------
| Localhost Testing
|--------------------------------------------------------------------------
|
| If your running your website locally and want to test different
| IP addresses to see location detection, set 'enabled' to true.
|
| The testing IP address is a Google host in the United-States.
|
*/
'testing' => [
'enabled' => true,
'ip' => '13.107.184.8',
],
From my understanding my server sees this ip address as my new ip and should deny access right? Please, can some one elaborate more of what's going on behind the scenes. Thank you @axlon and @nerg4l for your help.
Hello there,
I know that this is bit late, but @nerg4l has already spoke of most of the things i wanted to say.
The geo-routes
package depends on the stevebauman/location
package to retrieve the country code from the client IP in the middleware and then determine if the country is allowed or not. Take a look here.
The solution proposed by @nerg4l might not work because at the moment the geo-routes
package retrieves the IP manually and passes it to the get
method of the Location
class, which in fact is not a very good practice IMHO because the location
package is configured to work with a testing IP whenever in localhost.
I hope that this is what you're asking about and hope that you find my comment helpful 😄.
Hi @yak0d3 , thank you for taking the time to explain. I really appreciate 💯. I understand now. I will test the application on a live server.
Hi @UchennaPrudensia, I just tagged version 0.2.1 which should fix the problems you are having. Faking your IP through the method we talked about before should now work.
You can update the package by running the following command:
composer update laracrafts/laravel-geo-routes
@axlon , I just updated laracrafts/laravel-geo-routes and ran the application. The application still runs normally. It's not blocking the app. Thank you anyways. I will do a fresh install and try again. If it works I will update this post. Thanks!
Was wondering if this works on local machine. I am using vagrant. I just did a fresh install and tried the sample code below.
Route::get('/', function () { return view('welcome'); })->allowFrom('us');
then I get a 401|unauthorized. Did i miss something?