Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the font cannot be displayed when using a subdomain name to access the CSS of the root domain name

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what to do if the font cannot be displayed when accessing the CSS of the root domain using a subdomain name". In the daily operation, it is believed that many people have doubts about how to use the subdomain name to access the CSS of the root domain name when the font cannot be displayed. The editor consulted all kinds of materials and sorted out a simple and easy-to-use operation method. I hope it will be helpful for you to answer the question of "what to do if the font cannot be displayed when accessing the CSS of the root domain using a subdomain name"! Next, please follow the editor to study!

Problem description

Today, when using a subdomain name to access the CSS of the root domain name, it is found that the font cannot be displayed. After ensuring that the path loading of CSS and Font fonts is not a problem, it is basically due to cross-domain problems.

Add the addresses allowed by Access-Control-Allow-Origin through the Nginx module Http_Headers_Module

Console error message

Ccess to Font at 'http://w001.static.akhack.com/css/KohinoorBangla-Regular.ttf' from origin' http://carey.akhack.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://carey.akhack.com' is therefore not allowed access.

Solution method

Location ~ *\. (eot | ttf | woff | svg | otf) ${add_header Access-Control-Allow-Origin http://carey.akhack.com; add_header Access-Control-Allow-Headers XmurRequestedMuth; add_header Access-Control-Allow-Methods GET,POST,OPTIONS;}

Be careful

Add_header Access-Control-Allow-Origin http://carey.akhack.com;// only allows a single domain name or'*'. If'*'is not recommended, it will lead to security problems at this point. The study on "what to do if the font cannot be displayed when accessing the CSS of the root domain using a subdomain name" is over. I hope to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report