Laravel Object not found Error 404 - laravel

The laravel project runs at another system with a fixed ip.
If I access the project on another computer via this line:
http://61.211.45.158/appi/public/auth/login
(changed to original ip for privacy)
it works so far but if I login the url does change to this:
http://61.211.45.158/auth/login
and I get the error
Object not found ... 404
The laravel project works if I call it locally via localhost....
I do not know why this is happening really big thanks for any help.
EDIT:
I removed the authentification and somehow it show the page now just without the login and register, does anyone know why?
I commented this line:
Route::group(['middleware' => 'auth'], function ()
{

You have wrong web server configuration on the remote machine. Web server should be pointed to a public directory, for example /home/someuser/appi/public, but not to /home/someuser/. Edit Apache config file (do not edit .htaccess), you should have similar lines in it:
DocumentRoot "/path_to_appi/appi/public"
<Directory "/path_to_appi/appi/public">
Then restart Apache to make everything work.

Related

some laravel route not changing to https

There are some my route not going to HTTPS in my Javascript code
loadSettingTable("{{ route('setting.table.data.datatable') }}");
they become like this, so my datatable can't be load because mixed content.
loadSettingTable("http://*****.com/admin/data-setting-table/datatable");
but my css and JS file already become HTTPS.
I already give this on my AppServiceProvider and ENV
//AppServiceProvider.php on Boot
if(env('REDIRECT_HTTPS')) {
$url->formatScheme('https');
URL::forceScheme('https');
}
//.ENV
REDIRECT_HTTPS=true
But some of it work fine with this code, why my code with route name not giving https?
loadTableRealCommSumAgent("/agent/commissions-summary-member-ajax");
I found the error myself, but don't really know why this error happens on my production server not staging server. I remove $url->formatScheme('https'); because it giving some error on production but not always and it's fixed my problem.

lsapp.test on browser not giving the index page instead localhost/lsapp/public/ gives the home page

I have set up the environment for virtual hosts using Apache. I am facing three problems.
1) I am unable to go to the index page by using lsapp.test on my browser (I have set lsapp.test for 127.0.0.1 and also the same for the localhost. It gives a 404 error.
2) If I go to localhost/lsapp on the browser the whole directory is visible (I assume which means my virtual host is not working as it should be)
3) On the browser, http://localhost/lsapp/public/ leads me to my root.
Web.php is as follows:
Route::get ('/', function() {
return 'Hello World';
});
Gives me Hello world on the browser as expected. BUT the problem is if I try to navigate to my about page through
Route::get ('/about', function() {
return 'about';
});
It gives 404 error. I have been breaking my head for the past 2 days. This could be a simple problem but so far I haven't figured out a solution.
I have checked the httpd-vhosts.conf file in Apache folder and hosts file in System32>drivers>etc if I have done the right settings and it looks fine.
This question does not require codes
lsapp.test on the browser must go to the home page. Also, I must be able to browse other pages.
Your document root should be lsapp/public/ and index.php must catch all request.
Apache Vhost
DocumentRoot /var/www/html/your-project/public
See:
https://laravel.com/docs/master/deployment
https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/

Trying to set up CAS with my Laravel project

I am using subfission/cas for my application. I have followed all installation steps. I am using windows, if that matters. More precisely, I have configured the following:
I ran the following in my terminal
composer require "subfission/cas" "dev-master"
I configured my Kernel.php accordingly, adding the following:
'cas.auth' => 'Subfission\Cas\Middleware\CASAuth',
'cas.guest' => 'Subfission\Cas\Middleware\RedirectCASAuthenticated',
I ran the following command:
php artisan vendor:publish
I also set up my cas server in my cas.php config file:
'cas_hostname' => env('CAS_HOSTNAME', 'cas.myserver.me'),
'cas_real_hosts' => env('CAS_REAL_HOSTS', 'cas.myserver.me'),
What I want is a middleware for all my routes, so I added the following route rule in my routes:
Route::middleware(['cas.auth'])->group(function ()
{
Route::get('/', function ()
{
return view('welcome');
});
});
Basically, I want to redirect everyone who is not logged in to the login page whenever I access the main page (for now, I will add more routes in the future). What happens is that the users are redirected to the login page when they are not logged in, but after the login I receive the following error:
ErrorException (E_WARNING)
DOMDocument::loadXML(): Opening and ending tag mismatch: hr line 1 and body in Entity, line: 1
No matter what view I'm redirecting the user to. I tried the default welcome page as well as an empty view, but I still get the same error.
EDIT: I have used the dev-master branch from subfission/cas for the above error and after switching to 2.1.1, I get a different error:
session_name(): Cannot change session name when headers already sent
EDIT 2: I did some more digging and I enabled internal errors in my cas client class with:
libxml_use_internal_errors(true);
And now I get the following:
Authentication failure: SA not validated Reason: bad response from the CAS server
And the cas response is:
The thing is that I use the same cas server for another 2 projects and it works well for those (but those aren't laravel projects.
I know it's been a while, but for anyone else having issues like this, the issue is the protocol selected for which your web service communicates with your CAS(Central Authentication Service) provider. There are two main protocols used for SSO/CAS in this package:
SAML(Security Assertion Markup Language) version 1.1 & 2
CAS Protocol v3.0
[Confusingly enough, CAS protocol shares the same namespace as the service.]
The idea is to match the protocol and version with your identity provider. It sounds like your provider is using CASv3.0, which is why disabling SAML worked.
Also, if you enable debug mode, you will see further error details in your log file to help your troubleshoot.
Best of luck!
I managed to solve the issue by disabling the SAML in the cas configure file:
'cas_enable_saml' => env('CAS_ENABLE_SAML', true),
change to
'cas_enable_saml' => env('CAS_ENABLE_SAML', false),

Laravel subdomain accepts other similar subdomain which are not even pointed to the project

I have pointed some subdomains to my project in laravel, some similar subdomain exists on the same server, but pointed to other projects.
Still sometimes they point to my project.
How to resolve this issue?
route structure-
I have a wildcard route-
Route::group(array('domain' => '{subdomain}.website.com'), function () {
Route::get('/', function ($subdomain) {
});
});
My subdomain which are pointed to this project are-
Xyz.website.com, abc.website.com
but other links like feh.website.com which are pointed to other projects are sometimes pointing to my project.
Please help for above scenario .
I thought it depends on your web server config.
If you use nginx as web server, you should declare the server name:
{
...
servername xyz.website.com abc.website.com
...
}
If you get some else url point to your project like feh.website.com, that maybe because you did not declare settings for feh.website.com and it will go to your first virtual server.

Laravel error: Sorry, the page you are looking for could not be found

I need to update a website from a colleague to just add a LDAP connexion.
I use EasyPHP devserver 17.0 with php 7.1.3 and MySQL 5.7.17.
I've read a lot of docs etc to be started and to recover the site in local as it is working actually.
Everything was working so I began to add a login form etc... but when I tried to test a link from the website, it return me the error "Sorry, the page you are looking for could not be found". So I began to search on forums I found some results about routes etc and everything I've tested didn't worked.
So, I decide to use the backup from the website as it was when I juste restore it in local(I precise link to other page and everything was working). I check the link and again, "Sorry, the page you are looking for could not be found". I decide to try another developement tool and download XAMP, exactly same error. I tried with Wamp, Laragon always same error.
In the apache conf mod_rewrite is enabled.
My laravel framework version is: 5.5.39
So my folder look like:
Laravel 5.5.39
The content of routes > web.php:
Route::get('/', function () {
return view('welcome');
})->name('welcome');
// Holidays
Route::get('/holidays/create', 'HolidayController#create')->name('holidays.create');
Route::post('/holidays', 'HolidayController#store')->name('holidays.store');
Route::get('/holidays/{holiday}/delete', 'HolidayController#destroy')->name('holidays.destroy');
Route::get('/holidays/{holiday}/edit', 'HolidayController#edit')->name('holidays.edit');
Route::post('/holidays/{holiday}', 'HolidayController#update')->name('holidays.update');
// Leave types
Route::get('/types/create', 'TypeController#create')->name('types.create');
Route::post('/types', 'TypeController#store')->name('types.store');
Route::get('/types/{type}/delete', 'TypeController#destroy')->name('types.destroy');
Route::get('/types/{type}/edit', 'TypeController#edit')->name('types.edit');
Route::post('/types/{type}', 'TypeController#update')->name('types.update');
// Users
Route::resource('users', 'UserController');
Route::get('/births', 'UserController#getAllBirths')->name('births');
// Leaves
Route::get('/calendar', 'LeaveController#index')->name('calendar');
Route::post('/leaves', 'LeaveController#store')->name('leaves.store');
Route::post('/leaves/{leave}', 'LeaveController#update')->name('leaves.update');
Route::get('/leaves/{leave}/delete', 'LeaveController#delete')->name('leaves.delete');
Route::get('/leaves', 'LeaveController#getAll')->name('leaves');
Route::get('/config', 'ConfigController#index')->name('config');
// Stats
Route::get('/statistics', 'StatsController#index')->name('stats.index');
Auth::routes();
I don't know what I could do but please ask me if you need more information to help me.
If it can help; gitLab link from the site I'm trying to restore: https://gitlab.com/balsigergil/btplan
To fix the problem I had to change the VirutalHost DocumentRoot so the root is the public directory.
DocumentRoot "C:/Users/sadm-m263733/Desktop/EasyPHP-Devserver-17/eds-www/siteBTPlan/public"

Resources