iberezansky / flip-book-jquery

3D FlipBook allows to browse images, PDFs or HTMLs as a flipping book. It helps to attract user attention and make more impression on him.
http://3dflipbook.net/
GNU General Public License v2.0
224 stars 86 forks source link

"UnexpectedResponseException" 0 Response from server #21

Closed doubleprincez closed 1 year ago

doubleprincez commented 1 year ago

I tried testing this package in a laravel application but I kept receiving this error in the console.

"Unexpected server response (0) while retrieving PDF "http://127.0.0.1:8000/test/src/test.pdf"."

Reproduce

Create a new laravel application, add this package into a blade and add your pdf into src/ folder in a test folder in the project root like this public/test/src Also include all neccessary files in the same test folder. My Blade looks like this

<x-guest-layout>
    @section('styles')

        <style type="text/css">
            body {
                margin: 0;
                padding: 0;
            }

            .solid-container {
                height: 100vh;
            }
        </style>
    @endsection
    <div class="solid-container"></div>

    <script src="{{ asset('js/core/jquery.min.js') }}"></script>
    <script src="{{ asset('test/js/html2canvas.min.js') }}"></script>
    <script src="{{ asset('test/js/three.min.js') }}"></script>
    <script src="{{ asset('test/js/pdf.min.js') }}"></script>

    <script src="{{ asset('test/js/3dflipbook.min.js') }}"></script>
    <script type="text/javascript">
        $('.solid-container').FlipBook({
            pdf: '{{asset('test/src/test.pdf')}}'
        });
    </script>
</x-guest-layout>

Expected Result

Pdf should be displayed like it did in the demo app that i was testing with.

Result

Pdf files keeps coming as a downloadable file in my browser and the error on the console is as if the plugin is expecting a particular header response type which is not properly returned.

doubleprincez commented 1 year ago

While experimenting I wrote a service worker to help convert the request header to 'Content-Type': 'application/pdf', and return 200, and eventually the file is loaded successfully now.