[英]Stripe Elements won't load my custom font
I'm using this code to load a custom font for my Stripe card number element:我正在使用此代码为我的 Stripe 卡号元素加载自定义字体:
const elements = stripe.elements({
fonts: [
{
family: 'Avenir-Regular-Bold',
src: 'url(\'styles/AvenirNextLTPro-Bold.otf\')'
}
]
});
And I'm getting this error about loading said font:而且我收到有关加载所述字体的错误:
Access to font at 'https://example.com/app/styles/AvenirNextLTPro-Bold.otf' from origin 'https://js.stripe.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
CORS 策略已阻止从源“https://js.stripe.com”访问“https://example.com/app/styles/AvenirNextLTPro-Bold.otf”字体:否“访问控制允许” -Origin' header 存在于请求的资源上。
I have no idea what this means or why Stripe is saying this.我不知道这意味着什么,也不知道 Stripe 为什么这么说。 Any way I can get my custom font to load?
有什么办法可以让我的自定义字体加载?
I fixed it like this:我这样修复它:
<?php
header("Access-Control-Allow-Origin: *");
echo file_get_contents('https://example.com/AvenirNextLTPro-Bold.otf');
And then giving the url to this page to Stripe.然后将 url 给这个页面给 Stripe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.