invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
398 stars 264 forks source link

XMLHttpRequest error when requesting PDF files - after migrating between servers #530

Open mmaeffert opened 1 year ago

mmaeffert commented 1 year ago

How I migrated

dockerfiles/docker/app/public dockerfiles/docker/app/storage dockerfiles/config/hosts

services: server: image: nginx restart: always env_file: env volumes:

networks: invoiceninja:


- Using this env file:

IN application vars

APP_URL=http://placeholder.de APP_KEY=xxxxxxx APP_DEBUG=true REQUIRE_HTTPS=false PHANTOMJS_PDF_GENERATION=true PDF_GENERATOR=snappdf TRUSTED_PROXIES='*'

QUEUE_CONNECTION=database ...



- Had to switch from mysql to mariadb due to change in architecture
- Created database dump of old installation
- Manually pushed the dump into the new database

### My issue
When requesting invoices (either those created on old installation and the new installation), I get the error "XMLHttpRequest error.". It does not matter whether I want to access this via the customer portal, when trying to send the email or just viewing the invoice. 

I have tried:
- Different browsers
- `php artisan cache:clear`
- Rebuilt
- Restart
- New domain

## Error messages from browser console
The orange line is where I press "Show PDF"
The IP 10.0.0.1:8001 is the apps file inside my VPN

![tmppp](https://github.com/invoiceninja/dockerfiles/assets/100378374/84935671-1326-4b32-9953-5e93383b0fa3)
![image](https://github.com/invoiceninja/dockerfiles/assets/100378374/46e2bc79-c95d-4ca0-bae4-3e70b4c305ae)

Looking into the app container console, I get no error messages.
mmaeffert commented 1 year ago

It just occured to me that pdf.min.js is never properly loaded and the GET request never receives an answer. Neither the nginx or the app container throw any error messages and the file in question has 777 permission granted by me. Manually executing the GET request is successful. Furthermore I found the following error:

asdadada

I also do not know why the file is requested via HTTP. When I change the env to REQUIRE_HTTPS=true, nothing works anymore. In case it is needed, this is my Proxy Configuration:

<VirtualHost *:80>
        ServerName placeholder.de
        ProxyPreserveHost On
        ProxyRequests Off
        ServerAlias www.placeholder.de
        Redirect permanent / https://placeholder.de
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName placeholder.de
        ProxyPreserveHost On
        ProxyRequests Off
        ProxyPass / http://localhost:8001/
        ProxyPassReverse / http://localhost:8001/

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/placeholder.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/placeholder.de/privkey.pem
</VirtualHost>
</IfModule>
mmaeffert commented 1 year ago

Allowing unsafe content and removing the redirection onto HTTPS, I now do not receive any error messages anymore.

I also ask myself why the file is requested via HTTP, instead of HTTPS, when the env variable is set accordingly.

Now when I create an invoice, the preview is working fine. But when looking at the PDF later, it is just blank: image

Same result when downloading and opening seperately

CaffeinatedTech commented 1 year ago

I'm facing the same problem. pdf.min.js is blocked because it is requested on http instead of https. I'm using the helm chart, with Caddy running reverse_proxy to it.

The PDF is created fine, and gets attached to the email just fine, but I can't view the PDF from within IN. I'm assuming the client portal has the same problem.