Larave Pagination is showing localhost not my domain - laravel

I am using a laravel application where all my pagination URLs are wrong. They are not using my domain like https://example.com instead it is showing localhost:3000 on the live server.
All other URLs and routes are working fine but pagination has issues. Please guide, I have used
{-- $order->link() --}
{{ $orders->render() }}
also, I have tried
{!! str_replace(request()->server('SERVER_ADDR'), "example.com", $orders->links()) !!}
But it always shows localhost:3000

Related

My Vue+Laravel App doesn't want to do Vue on Heroku

I have a Laravel+Vue app that I successfully installed on Heroku and Laravel part works here (https://shoomilka-todoapp.herokuapp.com/), but my Vue code for this application doesn't want to work. Code you can see here https://github.com/shoomilka/todoapp.
Can you help me, please to fix the error of why Vue doesn't work on Heroku?
It works on local environment well.
Try inspect your website and look at the console tab. you will see this error.
Mixed Content: The page at 'https://shoomilka-todoapp.herokuapp.com/'
was loaded over HTTPS, but requested an insecure script
'http://shoomilka-todoapp.herokuapp.com/js/app.js?time=1590194712'.
This request has been blocked; the content must be served over HTTPS.
If your website delivers HTTPS pages, all active mixed content delivered via HTTP on this pages will be blocked by default.
The best strategy to avoid mixed content blocking is to serve all the content as HTTPS instead of HTTP. you can use laravel secure_assets method this generates a URL for an asset using HTTPS
<script src="{{ secure_assets('js/app.js') }}?time={{ time() }}"></script>
or simply just set 'url' => 'https://youDomain.com' in config/app.php and .env APP_URL=https://yourDomain.com

Force Route to HTTPS

I need help on setting up the laravel backpack on live server.
So at first i got trouble loading the asset since it used http for the image and css
http://example.com/images/ and http://example.com/css/
I can solve that problem using this code I got
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
The assets are loaded correctly (it shows https://example.com/images/... when i inspeced it)
But somehow some crucial contents are not loaded with https, here's the screenshot:
With the error
Access to XMLHttpRequest at 'http://example.com/admin/elfinder/connector' from origin 'https://example.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
Here's the code of the error
<!-- This file is used to store sidebar items, starting with Backpack\Base 0.9.0 -->
<li>
<a href="{{ backpack_url('dashboard') }}">
<i class="fa fa-dashboard"></i>
<span>{{ trans('backpack::base.dashboard') }}</span>
</a>
</li>
There are several thing that didnt't get updated to https as well such as some CSS(from the vendor/crud), scripts, the post method, and the logo
I think that I can copy paste the meta tag to the backpack_url, but I have no idea where is it or how it works.
I am very new to this, any suggestion is appreciated
Thanks!
It looks like your Laravel installation think that you are running on a HTTP server, while the client's request was made over HTTPS
These issues generally happen as a result of having a proxy in front of Laravel.
As a first point of call, ensure that your trusted proxy configuration is correct. This will cause Laravel to trust the X-Forwarded-Protocol header, and intern to generate the correct https URLs.
If you can't get the proxy configuration working, you can always force https URL generation by adding this in your AppServiceProvider
if($this->app->environment('production')) {
\URL::forceScheme('https');
}

Dominate vue router with Laravel router

I am building an application with Laravel and Vue.js. I am using vue router. With this I am controlling all routes. Now, I want to make an url xyz.com/admin which will different (Laravel new route, I want to work with this admin separately). I am using this below code, but not working.
Route::get(
'/admin/{view?}',
"AdminController#index"
);
Route::view('/{any}', 'home')->where('any', '.*');
I also remove the admin link from <router-link>
<v-list-tile-title v-if="isAdminMethod===true">
Admin Panel
</v-list-tile-title>
<v-list-tile-title v-else>
<router-link :to="{ path: i.to }">
{{ i.title}}
</router-link>
</v-list-tile-title>
How about you try something like
Route::get(
'/admin/{view?}',
"AdminController#index"
);
or it might be worth looking into something like InertiaJS.
Let me know if you have any further queries.

Laravel URL::asset for 404's view

I'm embellishing Laravel's 404 page (ressources/views/erros/404.blade.php). But, I can't load my CSS and JS files, which are, in my public folder.
Actually, Laravel is returning me localhost/css/bootstrap.css when it should return me localhost/myproject/public/css/bootstrap.css with {{ URL::asset('css/bootstrap.css') }}. While it's returning me localhost/myproject/public/css/bootstrap.css when I'm on another view (with the same code: {{ URL::asset('css/bootstrap.css') }}) on my home page wich is perfectly working.
By the way, I'm using Laravel 5.3.
Thanks in advance <3
Configure your webserver so the root of domain (localhost) points to public/ -folder.
Vagrant-solution like Homestead would probably make setting up the development-environment easier for you.

Best way to output html via blade in Laravel, with XSS protection

I need to output some html from database, which was filled by users via CKEeditor. So it may have some <script>alert('something');</script> or some other stuff. If i escape html output via blade {{ $news->body }} - i will get html as plain text which is not what i need. But if i use {!! $news->body !!} i will get normal html with working alert. Is there any clean way to deal with it?
For Laravel 5 and later there is Purifier which integrates the aforementioned HTMLPurifier nicely into Laravel.
Install it using composer require mews/purifier and then use
{!! clean($news->body) !!}
to output HTML that has been properly escaped with the default HTMLPurifier settings.

Resources