Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting CORS error when loading from font from s3 #454

Open
MohanRam1996 opened this issue Apr 2, 2024 · 0 comments
Open

Getting CORS error when loading from font from s3 #454

MohanRam1996 opened this issue Apr 2, 2024 · 0 comments

Comments

@MohanRam1996
Copy link

for dynamic fonts , i have stored my font in s3 bucket and when trying to access that via web font loader , iam getting CORS error

  //custom font
  await WebFont.load({
    custom: {
      families: [fontLibrary],
      urls: [customURL],
    },
    fontactive: (familyName, fvd) => {
      // console.log(`Font "${familyName}" has been loaded`);
      if (swalNeeded) {
        Swal.fire({
          icon: 'success',
          title: `Font "${familyName}" has been loaded`,
          showConfirmButton: false,
          timer: 1500,
        });
      }
      loaded = true;
    },
    fontinactive: (familyName, fvd) => {
      // console.log(`Font "${familyName}" failed to load`);
      if (swalNeeded) {
        Swal.fire({
          icon: 'error',
          title: `Font "${familyName}" failed to load`,
          showConfirmButton: false,
          timer: 1500,
        });
      }
    },
  });
  
  Note: this issue goes away when i disable cache from the chrome devtools -> network tab -> disable cache checkbox 
  
  when disable cache is enable , there is no issue 
  
  i also tried adding software based disable of cache in my react app but that did not work 
  
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />


moreover , all the access is public and there is no restriction on s3 side . 

how to fix this ? 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant