This topic is locked
[SOLVED]

Local Fonts in PHPRunner 10.8 (adding .htaccess) ?

7/16/2022 11:42:54 PM
PHPRunner General questions
Davor Geci authorDevClub member

The local fonts work perfectly in new PHPRunner 10.8 but only locally.
When I upload the project to webserver I'm getting error:

Access to font at 'https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf'>https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf'>https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf'>https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf' (redirected from 'https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf'>https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf'>https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf'>https://MYDOMAIN/fonts/BarCode_mrvcode39extma.ttf') from origin 'https://MYDOMAIN' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Found on internet that we can solve this by adding .htaccess file and adding 3 lines of code in there. Can we add .htaccess to PHPRunner projects? Or is there a workaround for this local fonts problem on webservers?

Here is the link to the .htaccess solution:
configure-cors-to-resolve-web-font-issues

Davor Geci authorDevClub member 7/27/2022

How to use local fonts on a webserver that blocks with CORS policy?

Sergey Kornilov admin 7/27/2022
Davor Geci authorDevClub member 7/27/2022

Here are the 2 errors from the console that I'm getting when loading the page with local font:

First:

Access to font at 'https://winpis.com/fonts/BarCode_mrvcode39extma.ttf' (redirected from 'https://www.winpis.com/fonts/BarCode_mrvcode39extma.ttf'>https://www.winpis.com/fonts/BarCode_mrvcode39extma.ttf') from origin 'https://www.winpis.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

And the second error:

winpis.com/fonts/BarCode_mrvcode39extma.ttf:1 Failed to load resource: net::ERR_FAILED

And here is from the Issues:

Ensure CORS response header values are valid
A cross-origin resource sharing (CORS) request was blocked because of invalid or missing response headers of the request or the associated preflight request .
To fix this issue, ensure the response to the CORS request and/or the associated preflight request are not missing headers and use valid header values.
Note that if an opaque response is sufficient, the request's mode can be set to no-cors to fetch the resource with CORS disabled; that way CORS headers are not required but the response content is inaccessible (opaque).
1 request
Request Status Preflight Request (if problematic) Header Problem Invalid Value (if available)
BarCode_mrvcode39extma.ttf blocked Access-Control-Allow-Origin Missing Header

I have uploaded the project to a demo account that is bound to my email davor.geci gmail.com but with some errors about a database not created while uploading the project.

Davor Geci authorDevClub member 7/27/2022

Not sure, but I think that the code generated is wrong.
My web app is not in the root of my domain but in a folder called "hewams" but this is missing, fonts are located at

'https://winpis.com/hewams/fonts/BarCode_mrvcode39extma.ttf'

and not at the location that the error is showing

Sergey Kornilov admin 7/27/2022

I can see two issues here and neither one is PHPRunner related.

  1. Redirect from https://www.winpis.com/ to https://winpis.com/ . You either need to remove that redirect or change CORS policy so both domains are treated the same way.


  2. You need to make sure your web server supports downloading ttf. Usually you need to add .ttf to the MIME types supported by the web server.



Davor Geci authorDevClub member 7/30/2022

Thanks for your reply admin.

The problem was solved by creating a folder "fonts" in the root of my domain and copying the fonts from the app "fonts" folder to the domain root "fonts" folder.
There is a wrong reference in the generated php code.