I am trying to load fonts from a subdomain different from the Node-RED subdomain in a template node, but this fails with this error:
Access to font at 'https://www.mydomain.tld/path/to/font.woff2' from origin 'https://node-red.mydomain.tld' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am running Node-RED from the official Docker image behind Traefik as a reverse proxy.
I tried to enable the CORS settings in settings.js like this:
This did not help.
I also tried to put the following labels into my docker-compose.yml for Traefik:
And in my docker-compose.yml for Node_RED:
No success. What would be a functioning solution?
CORS is set by the endpoint server not the requester
In this case here, you are requesting from your browser to a traefik server
In simple terms, the issue is not with node-red but with the endpoint serving the data/resource/font - which in this case is traefik.
Search the net for "traefik CORS" - there are lots of threads, or head to the traefik forums.
In case anyone else has this problem: Of course, it was an error on my part. Not Node-RED has to submit the relevant headers, but the other service (in my case a dockerized Apache webserver). Normally you do not need to change your Traefik configuration. I added this to the docker-compose.yml of my Apache container:
# CORS for Node-RED
If you do not want to explicitely name the domains, you can use a wildcard. But for whatever reason, this line did NOT work for me:
But kind of a dirty trick did work:
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.