I am using XAMPP and I installed a fresh Laravel 5.8 with composer create-project --prefer-dist laravel/laravel larascopy in C:\xampp\htdocs\larascopy
I can access it by going to: http://localhost/larascopy/public/
And then installed Telescope with these commands from the Guide:
composer require laravel/telescope
php artisan telescope:install
php artisan migrate
Then I can open Telescope like this http://localhost/larascopy/public/telescope
But all the links are wrong! They are pointing to: http://localhost/telescope/...
So I get all these errors in Console..
POST http://localhost/telescope/telescope-api/commands?tag=&before=&take=50&family_hash= 404 (Not Found)
POST http://localhost/telescope/telescope-api/commands?tag=&before=&take=50&family_hash= 404 (Not Found)
POST http://localhost/telescope/telescope-api/schedule?tag=&before=&take=50&family_hash= 404 (Not Found)
app.js?id=8776cf12ba6d7c72f145:1 Uncaught (in promise) Error: Request failed with status code 404
Is there a way to tell telescope the correct path?
I finally found a solution (for anyone else who might come across this issue).
<!-- Global Telescope Object -->
<script>
window.Telescope = @json($telescopeScriptVariables);
</script>
to this
<!-- Global Telescope Object -->
<script>
window.Telescope = @json($telescopeScriptVariables);
window.Telescope.path = 'your_project_folder/public/telescope';
</script>
You need to change Telescope path by overriding telescope layout, for that you need to follow some steps as given below.
This solution is also work for telescope laravel project created in sub-folders.
Step 1: Copy layout file from following path
File Path: project_directory/vendor/laravel/telescope/resources/views/layout.blade.php
Step 2: Paste that copied file to following path
File Path: project_directory/resources/views/vendor/telescope/layout.blade.php
You need to create vendor/telescope folder in resources/views directory.
Step 3: Change layout.blade.php file
File Path: project_directory/resources/views/vendor/telescope/layout.blade.php
Original:
<!-- Global Telescope Object -->
<script>
window.Telescope = @json($telescopeScriptVariables);
</script>
Updated:
<!-- Global Telescope Object -->
<script>
window.Telescope = @json($telescopeScriptVariables);
var telescopePath = "{{ ltrim(parse_url(url(config('telescope.path')))['path'], '/') }}";
window.Telescope.path = telescopePath;
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With