I've just grabbed our Laravel app from our repo, done composer update --no-scripts, run the artisan... commands to refresh the database and clear the cache, as per normal.
I come to log in. Nothing happens.
It's as if the form isn't submitting. I can see the POST being sent, there's a <input type="hidden" name="_token" value="xxxxxx"> in the form. But...Nothing. The network tab in chrome tells me there's a 301. If I break the database connection string in .env to something invalid, there's no error. Presumably because it's not hitting the server at all.
I've checked with php artisan route:list and the all the expected routes are there, including login
| | POST | login | | App\Http\Controllers\Auth\AuthenticatedSessionController#store | web |
| | | | | | guest |
I can't fathom what I've missed. Any pointers, please :)
Turns out that the server wasn't properly configured for https.
I noticed that the <form action was http:// rather than https:// and so none of the app's forms were submitting, including login.
Fixing the server config meant that Laravel inserted the right protocol into the form actions, and everything was jolly.
Hope this saves someone else the few hours I wasted trying to debug this badboy.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm setting up e2e tests using Laravel Dusk and I'm having problems trying to figure out how to test Laravel's authentication.
I am migrating a database using DatabaseMigrations trait and populating it with 1 record ( running setUp method which mocks up a user ). I tried to login with this specific user using the loginAs() method but it doesn't log me in.
My AuthenticationTest.php file
use DatabaseMigrations;
public function setUp(): void
{
parent::setUp();
factory('App\User')->create();
}
public function an_authenticated_user_will_see_an_account_button()
{
$this->browse(function (Browser $browser) {
$browser
->loginAs(User::find(1))
->visit('http://recipemanager.test/recipes')
->assertSee('Account');
});
}
My dusk routes
| | GET|HEAD | _dusk/login/{userId}/{guard?} | | Laravel\Dusk\Http\Controllers\UserController#login | web |
| | GET|HEAD | _dusk/logout/{guard?} | | Laravel\Dusk\Http\Controllers\UserController#logout | web |
| | GET|HEAD | _dusk/user/{guard?} | | Laravel\Dusk\Http\Controllers\UserController#user | web |
Note that I haven't touched any controllers, files related to Laravel Dusk!
I am not using a testing database for my tests and I know that's bad I'm getting into it don't hate me.
Steps to reproduce the bug ( You need to have XAMPP ):
1. Clone the repo
2. Switch to branch account
2. Configure the .env file to match your database
3. Make sure to configure vhosts Apache file and etc/hosts file so you can access recipemanager.test as home route ( 127.0.0.1 recipemanager.test )
4. Run php artisan dusk
Errors:
1)Tests\Browser\AuthenticationTest::an_authenticated_user_will_see_an_account_button
Did not see expected text [Account] within element [body].
Failed asserting that false is true.
I fixed the problem by visiting recipes visit('/recipes'). The problem was in the environment file -> APP_URL was set to localhost and Dusk was trying to visit localhost:800/recipes. I checked that by asserting full URL
$this->browse(function (Browser $browser) {
$browser
->loginAs(User::find(1))
->visit('/recipes')
->assertUrlIs('http://recipemanager.test/recipes');
});
Error: Actual URL [http://localhost/recipes] does not equal expected URL [http://recipemanager.test/recipes].
.env file
APP_URL=http://localhost
After I changed the APP_URL to http://recipemanager.test and visit /recipes everything is working fine!
I'm trying to learn Laravel (5.3.28) and I'm running into an issue with my very first api route not working. I've followed the Laravel docs and can create a new project and can navigate to the Laravel splash screen indicating it's working. I added the following route to routes/api.php to test if I can consume the end-point, but I get an error:
routes/api.php
Route::get('foo', function () {
return 'Hello World';
});
error
NotFoundHttpException in RouteCollection.php line 161:
I have a dedicated CentOS box running XAMPP for my web server. the address to hit the end-point is http://10.0.0.200/test/api/public/foo.
I'm read that my .htaccess file should be edited, but the few examples I found match what I already have, so I'm a little lost on what to do.
Here is the output for php artisan route:list:
+--------+----------+----------+------+---------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+----------+------+---------+--------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/foo | | Closure | api |
| | GET|HEAD | api/user | | Closure | api,auth:api |
+--------+----------+----------+------+---------+--------------+
10.0.0.200/test/api/public is the root URL I assume. If yes, then you need to hit 10.0.0.200/test/api/public/api/foo
I think that your project lies in the folder test/api, what you need is to reconfigure apache\nginx to route all requests going to 10.0.0.200/test/ , to start going to {webser root}/test/api/public . This is done in web server configuration files
Laravel uses the artisan commands to do several development tasks, such as running a built-in web server. You can do this by opening a new terminal inside the root directory of your project (where the artisan script is located) and run the following command :
php artisan serve
This should notice you with the URL of the built-in web server. You can then access it through your web browser. Generally, http://localhost:8000
This way, you'll be able to access your route which heads to http://localhost:8000/foo and in which you should find the page that says Hello world as your return in your closure.
I have install the Dingo with composer, and change the app.php file. After configure the app.php file, then i have publish vendor that, and get the api.php file.
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', ['namespace' => 'App\Http\Controllers'], function ($api) {
$api->get('users', 'EventsController#index');
});
Then i try php artisan api:routes
This is my result:
+----------------+----------------+------+---------+-----------+------------+----------+
| Host | URI | Name | Action | Protected | Version(s) | Scope(s) |
+----------------+----------------+------+---------+-----------+------------+----------+
| api.kayice.com | GET|HEAD users | | Closure | No | v1 | |
+----------------+----------------+------+---------+-----------+------------+----------+
Then i php artisan serve go to localhost:8000/user
It just show me this Sorry, the page you are looking for could not be found.
Could that anything is might miss for that?
Edited
I have added the provider in the app.php, i think after the vendor publish, the api working, then everythings should working. Or else is the laravel 5.2 problem?
I figure out what is the problem now, i didnt add the prefix in the api.php. Therefore it didnt return me the value.
Edited
But it still does not, most probably the system still no yet support well
I have created a Google AppEngine and loaded the Drupal extension http://blog.boombatower.com/drupal-integration-module-google-app-engine
This loaded and ran correctly.
I then added the rest of an existing Drupal site, and added some extra entries in the settings.php file to handle additional facilities, including memcache and FB
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
// The 'cache_form' bin must be assigned no non-volatile storage.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'something_unique';
require_once "sites/all/libraries/purl-master/src/Purl.php";
include "sites/all/modules/fb/fb_url_rewrite.inc";
include "sites/all/modules/fb/fb_settings.inc";
When I load the site to the AppEngine and then view I get errors regarding files not found. These are image files which have a space character in the name. The referencing URL looks correct. Other image files without a space in the name work correctly.
17:32:41.844 Static file referenced by handler not found: __static__/sites/default/files/images/frontpage/Titan%20#%20Kiva%20Beach.jpg
I will move this and my other files to Cloud storage after I have the basics running.
When I check for instances of the AppEngine none are showing. Yet the site loads and runs / partially, I have issues with responsive menus which is preventing me access the admin and other pages
Warning: Invalid argument supplied for foreach() in responsive_menus_glob_recursive() (line 491 of /base/data/home/apps/s~app-laketahoe-com/1.374191105859253183/sites/all/modules/responsive_menus/responsive_menus.module).
Not sure if this is related.
I wanted to SSH into the AppEngine to look at the file system but can't find it listed in the instances. I had added the Compute Engine at a later date but it should be independant of the App Engine.
greg#ubuntu:~$ gcutil listinstances
+------------------+---------------+---------+--------------+---------------+
| name | zone | status | network-ip | external-ip |
+------------------+---------------+---------+--------------+---------------+
| vm-laketahoe-com | us-central1-b | RUNNING | 10.240.36.10 | 23.251.150.90 |
+------------------+---------------+---------+--------------+---------------+
Thanks in advance
I don't believe filenames with spaces in them are supported at all.
Also there is a bug with glob() calls not working which might be the Warning you're seeing.
Lastly you cannot SSH into app engine. The admin console for your app engine apps is at https://appengine.google.com/
So I have created my web page based on PyroCMS, adding some custom modules. Developing was done on localhost using wampserver. Now I need to put this website online, so I'm trying to test it using free hosting. I uploaded my project folder on webhost, imported database, changed database.php file for new connection settings.
But, when trying to custom modules from web site, I get message: "We cannot find the page you are looking for, please click here to go to the homepage."
What am I missing here? Everything was working good on localhost, I guess there is something I havent changed :/
Edited:
Maybe this helps - in control panel/add-on I get this error message:
Message: Invalid argument supplied for foreach()
Filename: models/module_m.php
Line Number: 479
The default URI_PROTOCOL is wrong, or not correctly detected by your host. Play with the settings in config/config.php. I have the most success with PATH_INFO instead of AUTO
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'PATH_INFO';