# Resolving CORS Error in Taiga Development Environment

**URL:** https://community.taiga.io/t/resolving-cors-error-in-taiga-development-environment/3603
**Category:** Troubleshooting
**Created:** [June 28, 2024, 2:17pm UTC](https://community.taiga.io/t/resolving-cors-error-in-taiga-development-environment/3603 "2024-06-28T14:17:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Subash\_Shanmugam](https://dub1.discourse-cdn.com/flex017/user_avatar/community.taiga.io/subash_shanmugam/32/2607_2.png) [@Subash\_Shanmugam](https://community.taiga.io/u/Subash_Shanmugam)
#### Post date: [June 28, 2024, 2:17pm UTC](https://community.taiga.io/t/resolving-cors-error-in-taiga-development-environment/3603/1 "2024-06-28T14:17:56Z")

</div>

Hi Taiga Community,

I’m currently setting up a development environment for Taiga on Ubuntu server via vm ware, the steps followed by and have encountered a Cross-Origin Resource Sharing (CORS) error when trying to access the Taiga front-end. I’ve tried several configurations, but the issue persists. Here’s a brief overview of my setup and the steps I’ve taken:

### Setup Overview

- **OS:** Ubuntu
- \*\*Taiga Version:6.8.0
- **Backend:** Django python3.8
- **Frontend:** (Taiga front-end)
- **Web Server:** Nginx
- **Database:** psql (PostgreSQL) 12.19 (Ubuntu 12.19-1.pgdg24.04+1)

### Issue

When I try to access the front-end, I receive the following CORS error in the browser console:

```auto
The stylesheet http://taskusfdev.thepermatech.pit/v-1719498476318/styles/theme-taiga.css was not loaded because its MIME type, “text/html”, is not “text/css”

```

Additionally, there are CORS errors when making API requests.

### Steps Taken

#### 1. **Configured CORS in Django (Taiga Back-end)**

- **Installed `django-cors-headers`** :

```bash
pip install django-cors-headers

```

- **Updated `settings.py`** :

```python
INSTALLED_APPS = [
    ...
    'corsheaders',
    ...
]

MIDDLEWARE = [
    ...
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    ...
]

CORS_ALLOWED_ORIGINS = [
    "http://your_frontend_domain",
    "http://another_allowed_domain",
]

```

Tried allowing all origins:

```python
CORS_ALLOW_ALL_ORIGINS = True

```

- **Restarted the Django server** :

```bash
python manage.py runserver

```

#### 2. **Configured Nginx**

- **Nginx Configuration for the back-end** :

```nginx
server {
    listen 80;
    server_name your_backend_domain;

    location / {
        proxy_pass http://192.168.1.100:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Add CORS headers
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain; charset=utf-8';
            add_header 'Content-Length' 0;
            return 204;
        }

        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
    }
}

```

Despite these configurations, the CORS error persists. I suspect there might be additional steps or configurations that I’m missing.

### Questions

1. **Is there a specific configuration for Taiga that I might be missing?**
2. **Are there known issues or additional settings required to resolve CORS errors in the Taiga development environment?**
3. **Any advice or guidance from those who have successfully set up Taiga as development environment would be greatly appreciated!**

Thank you in advance for your help!

Best regards,  
Subash S

---

<div class="post-metadata">

### Author: ![Charlie](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@Charlie](https://community.taiga.io/u/Charlie)
#### Post date: [July 1, 2024, 6:50am UTC](https://community.taiga.io/t/resolving-cors-error-in-taiga-development-environment/3603/2 "2024-07-01T06:50:59Z")

</div>

Hi there,

I found [this thread](https://community.taiga.io/t/stylesheet-not-loading-properly/2231/9) where they discuss an error similar to yours, does this help?

In their case, it’s not a development environment, though most things should still apply.

Best regards!

---

<div class="post-metadata">

### Author: ![Subash\_Shanmugam](https://dub1.discourse-cdn.com/flex017/user_avatar/community.taiga.io/subash_shanmugam/32/2607_2.png) [@Subash\_Shanmugam](https://community.taiga.io/u/Subash_Shanmugam)
#### Post date: [July 23, 2024, 1:35pm UTC](https://community.taiga.io/t/resolving-cors-error-in-taiga-development-environment/3603/3 "2024-07-23T13:35:52Z")

</div>

Thanks for your reply,  
In my issue I’ve missed to add the below headers in the taiga back end  
taiga-back\settings\common.py

CORS\_ALLOW\_HEADERS = [  
‘x-session-id’,  
‘content-type’,  
‘accept’,  
‘origin’,  
‘authorization’,  
‘x-csrftoken’,  
‘x-requested-with’,  
‘x-lazy-pagination’,  
‘x-disable-pagination’,  
‘set-orders’,  
]
