ihsaan
February 5, 2022, 6:55pm
1
When I try viewing a PDF invoice the system hangs and I get the following error in the console? Not sure if it helps but im using cloudflare
index.php#/:1 Access to XMLHttpRequest at ‘https://mydomain.com/invoice/public/client/invoice/Rr5LPpY9XwuNqsKPLEBkT4awBwiJFHfB/download?t=1644087174964&per_page=999999 ’ from origin ‘https://www.mydomain.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.
and then the following error:
index.php#/:1 WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
hillel
February 5, 2022, 7:43pm
2
Hi,
@david any thoughts?
You may want to try with the desktop app
ihsaan
February 5, 2022, 7:44pm
3
Will do and let you know… Thanks
ihsaan
February 5, 2022, 7:48pm
4
But what’s causing the CORS issue in case I want to use the web version?
ihsaan
February 5, 2022, 7:58pm
5
I’ve tried the windows app and I get the following error when trying to view PDF:
500: Internal Server Error
There was an error generating the PDF with Phantom JS
hillel
February 5, 2022, 7:59pm
6
Are there any details about the error in storage/logs
ihsaan
February 5, 2022, 8:18pm
7
I tried again now in order for it to log the error then it worked. Will try a few more times and let u know
ihsaan
February 5, 2022, 8:22pm
8
Where will I find the error log? Nothing appears on the server and in the app > dashboard > system log there is nothing related to the error either
ihsaan
February 5, 2022, 8:22pm
9
It happened again… So it seems to work sometimes and othertimes it doesn’t
ihsaan
February 5, 2022, 8:26pm
10
Do I perhaps need to run php artisan optimize? I’ve got shell access to my server, how would I run it?
david
February 6, 2022, 2:27am
11
@ihsaan
Are you on the latest version of the application?
ihsaan
February 6, 2022, 3:54am
12
Yes its the latest v5.3.55 c76
NZNinja
February 6, 2022, 3:59am
13
You can find the error log file here:
ihsaan
February 6, 2022, 4:13am
14
Oh sorry about that. This is from the error log:
[2022-02-05 19:57:54] production.INFO: https://mysite.com/invoice/public/phantom/invoice/VScl5C8nOxdUCqJJZ5sgGeCVYcYrrSpA?phantomjs_secret=secret
[2022-02-05 19:57:55] production.ERROR: There was an error generating the PDF with Phantom JS {"exception":"[object] (App\\Exceptions\\PhantomPDFFailure(code: 0): There was an error generating the PDF with Phantom JS at /home2/mysite/public_html/invoice/app/Utils/PhantomJS/Phantom.php:150)
[stacktrace]
NZNinja
February 6, 2022, 4:49am
15
Is PHANTOMJS_PDF_GENERATION=true
in your .env
file?
Could you try a different PDF generation method and see if that fixes it?
Also:
If you’re using the anonymous key you may have exceeded the limit, if that’s the case you can create an account to increase it. https://invoiceninja.github.io/docs/self-host-troubleshooting/#phantom-js
Make sure that you run php artisan optimize
after editing your .env
file.
Here is somebody with your exact issue: https://forum2.invoiceninja.com/t/error-on-pdf-generation-with-phantom/8693
ihsaan
February 6, 2022, 5:17am
16
Sorry about all the noob questions but how do I run php artisan optimize
ihsaan
February 6, 2022, 7:26am
17
I have registered with PhantomJSCloud, should I keep the secret key as “secret”
NZNinja
February 6, 2022, 7:57am
18
No problem mate that’s what the community is here for!
Are you running shared hosting? If so add this to the end of your URL: ?clear_cache=true
Change the key to whatever your PhantomJS secret key is. It is located on your PhantomJS profile.
ihsaan
February 6, 2022, 8:45am
19
PhantomJS only gives an API I cant seem to find the secret key. So I used the api key in the .env file however I left secret="secret"
ihsaan
February 6, 2022, 12:59pm
20
How do I run artisan optimize?