The @font-face feature is malfunctioning on the nginx server, but it seems to be working fine on localhost

I have a font file that I've set to @font-face using the following CSS code:

@font-face {
  font-family: 'MyCustomFont1';

  src:
    local('MyCustomFont1'),
    url('IRANSansXV.woff2') format('woff2'),
    url('IRANSansXFaNum-DemiBold.woff') format('woff'),
    url('Digi Lotos Bold.ttf') format('ttf');

}

Then, I set the font family for the body like this:

body {
  font-family: MyCustomFont1;
  font-variation-settings: "wght" 400, "rdot" 0.5
}

Everything was working fine on my localhost, but when I uploaded it to the nginx server, the font didn't display correctly.

In my mime.types file, I have specified the following types for fonts:

GNU nano 6.2                                          mime.types                                                   types {
    font/ttf                              ttf;
    font/otf                              otf;
    font/woff                             woff;
    font/woff2                            woff2;

    application/x-font-ttf                ttf;
    font/opentype                         otf;
    application/vnd.ms-fontobject         eot;
    font/x-woff                           woff;
    application/font/woff2                woff2;
    application/font-woff                 woff;

I also added configurations to my nginx server for serving fonts:

server {

        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        location ~* \.(eot|ttf|woff|woff2)$ {
                add_header Access-Control-Allow-Origin *;
        }

        location ~* \.(eot|otf|ttf|woff|woff2)$ {
                add_header Access-Control-Allow-Origin *;
                expires max;
        }

Unfortunately, despite everything working fine on localhost, the font was not displaying correctly on the server and default system font was used instead.

Answer №1

I stored my custom font on a different server and linked to it in the URL field, allowing me to successfully retrieve the file.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

React makes the input field vanish when the value length reaches zero

Here's a component I'm working with: const SelectFieldOptions = ({ editedField, fieldMethods }: any) => { const items = editedField.fieldOptions.map((e: any) => { return ( <div key={e.id}> <input type="text" on ...

Leveraging useEffect and useState in Next.js

I'm struggling to grasp the concepts of useState and useEffect, it seems like I may have jumped ahead too quickly. Currently, I have an array containing different words: const words = ["There", "Their", "They're", "Were"]; My goal is to display ...

The navigation bar is currently arranged in a stacked formation, but it is not lined up as

Just dipping my toes into web development and experimenting with Bootstrap. Here's a snippet of my code: <!DOCTYPE html> <html> <head> <title>IMAGE GALLERY</title> <link rel="stylesheet" type="te ...

Would you prefer to showcase data in a horizontal format instead of a vertical one

My issue lies with a table that pulls data from a database. My goal is to showcase each staff member in a horizontal layout, but at the moment, they are appearing vertically. include 'includes/connect.php'; $select_staff = "select * FROM staff" ...

How can the CORS issue be resolved when sending a form from a client to an AWS API gateway function?

Within my front end React application, I am looking to implement a contact form that will submit data to a Lambda function via an API Gateway with a custom domain attached. The frontend operates on the domain dev.example.com:3000, while the API Gateway is ...

Mastering Data Transmission: Sending and Receiving Various Data Types Between React and Flask

Looking to send both user image and user data together to create a user on the backend using Flask. Currently, I am sending it as parameters but would like to include everything in the body of a POST request in React. React: const newData = new FormData( ...

What is the specific procedure for installing pm2 on an offline RHEL system?

Just to clarify, this is not a duplicate question of the following: How to install npm -g on offline server I have successfully installed npmbox (https://github.com/arei/npmbox) on my offline REHL server. However, I am still unsure about how to install p ...

What exactly do discrete animations entail?

In the MDN animation documentation, it mentions a type of animation known as "discrete". Can you explain what this term signifies? ...

Unable to Remove Border From Image Link in Chrome and Firefox (Works in IE8)

I have implemented a jQuery menu on a Master page, where the menu structure is created using an Unordered List. Each list item contains an anchor tag which includes an image tag and a couple of spans. The functionality of the menu is such that only text i ...

Issue with color display inconsistency in webgrid across various segments

https://i.sstatic.net/UW17M.png My goal is to display section status colors in a webgrid and divide them percentage-wise, but I am facing issues with some of the rows. Here is the cshtml script for the webgrid section status: webGrid.Column(header: "Sec ...

Using JQuery to apply a CSS class or check for a CSS class on multiple button elements that

Being new to Jquery and Javascript, I am facing challenges in understanding how to implement the following. Throughout my site, I use the same button class, and I am attempting to make Jquery apply a "clicked" class only to the button that was clicked, no ...

Error encountered: The JSONP request to https://admin.typeform.com/app/embed/ID?jsoncallback=? was unsuccessful

I encountered an issue with the following error message: Error: JSONP request to https://admin.typeform.com/app/embed/id?jsoncallback=? Failed while trying to integrate a typeform into my next.js application. To embed the form, I am utilizing the react-ty ...

The error message "TypeError: event.preventDefault is not a function when using Formcarry with React Hook Form" is

How do I implement form validation using React Hook Form and Formcarry together? Something seems to be missing in my code or there might be a logic error Take a look at my code snippet: import { useForm } from "react-hook-form"; import { useFor ...

Tips for avoiding image overlap in a multi-carousel display

I am facing an issue with a bootstrap4 multi-carousel where the images are overlapping each other, taking up the entire screen width one by one. My implementation includes HTML, CSS, and JS files. <div class="row"> <div class="MultiCarous ...

Bootstrap Carousel fails to function properly

I have tried everything, even using code directly from ww3 with added cdn. It worked on bootstrap 4 beta, but the rest of my site is using an earlier version. I'm new at this and hesitant to mix versions unnecessarily. <!DOCTYPE html> <html ...

Altering the character by striking a key

I have a canvas with custom styling. In the center of the canvas is a single letter. Please see the code below for reference. The goal is to change the displayed letter by pressing a key on the keyboard. For instance: Letter A is centered in the canvas: P ...

React: Using useState and useEffect to dynamically gather a real-time collection of 10 items

When I type a keystroke, I want to retrieve 10 usernames. Currently, I only get a username back if it exactly matches a username in the jsonplaceholder list. For example, if I type "Karia", nothing shows up until I type "Karianne". What I'm looking f ...

Scrollable tabs with FlatLists inside a ScrollView, reminiscent of the layout found on popular social media profile

I am seeking to implement a set of tabs, each containing a FlatList within a ScrollView, similar to the layout seen on Instagram or Twitter. However, I have encountered challenges with having a FlatList within a ScrollView and triggering the onEndReached ...

Guide to creating a React Hooks counter that relies on the functionality of both a start and stop button

I am looking to create a counter that starts incrementing when the start button is clicked and stops when the stop button is pressed. Additionally, I want the counter to reset to 1 when it reaches a certain value, for example 10. I have tried using setInte ...

Alignment issue with column headers in Bootstrap Table

https://i.sstatic.net/nKtgx.png <table class="table"> <thead> <tr class="d-flex"> <th class="col-0">JOB ID&l ...