Skip to content

Commit 2199e05

Browse files
committed
fix: cors all origin access blocked
1 parent 4aa296c commit 2199e05

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

cvat/apps/engine/mixins.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,8 @@ def init_tus_upload(self, request):
295295

296296
tus_file = TusFile.create_file(metadata, file_size, self.get_upload_dir())
297297

298-
location = request.build_absolute_uri()
299-
if 'HTTP_X_FORWARDED_HOST' not in request.META:
300-
location = request.META.get('HTTP_ORIGIN') + request.META.get('PATH_INFO')
298+
backend_base_url = settings.CVAT_BASE_URL
299+
location = backend_base_url + request.META.get('PATH_INFO')
301300

302301
if import_type in ('backup', 'annotations', 'datasets'):
303302
scheduler = django_rq.get_scheduler(settings.CVAT_QUEUES.CLEANING.value)

cvat/apps/notifications/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def MarkNotificationAsViewed(self, request: Request):
297297
"data": {},
298298
"error": None
299299
},
300-
status = status.HTTP_404_NOT_FOUND
300+
status = status.HTTP_400_BAD_REQUEST
301301
)
302302

303303
return Response(

cvat/settings/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
3939
BASE_DIR = str(Path(__file__).parents[2])
4040

41-
# ALLOWED_HOSTS = ["*"]
4241
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
4342
INTERNAL_IPS = ['127.0.0.1']
4443

45-
# CORS_ORIGIN_ALLOW_ALL = True
44+
CORS_ALLOWED_ORIGINS = [
45+
"http://localhost:3000",
46+
"http://127.0.0.1:3000",
47+
"https://app.audino.in",
48+
]
49+
CORS_ALLOW_CREDENTIALS = True
4650

4751
def generate_secret_key():
4852
"""

cvat/settings/development.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# Django-sendfile:
1717
# https://github.com/moggers87/django-sendfile2
1818
SENDFILE_BACKEND = 'django_sendfile.backends.development'
19+
CVAT_BASE_URL = 'http://127.0.0.1:7000'
1920

2021
# Cross-Origin Resource Sharing settings for CVAT UI
2122
UI_SCHEME = os.environ.get('UI_SCHEME', 'http')

0 commit comments

Comments
 (0)