From patchwork Wed Aug 11 21:36:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1516038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=L3AMbNX+; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GlNTp6vwjz9sXN for ; Thu, 12 Aug 2021 07:38:06 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GlNTp5LPFz3cJ0 for ; Thu, 12 Aug 2021 07:38:06 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=L3AMbNX+; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=that.guru (client-ip=136.175.108.45; helo=mail-108-mta45.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=L3AMbNX+; dkim-atps=neutral Received: from mail-108-mta45.mxroute.com (mail-108-mta45.mxroute.com [136.175.108.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GlNTB092Xz3bWJ for ; Thu, 12 Aug 2021 07:37:33 +1000 (AEST) Received: from filter004.mxroute.com ([149.28.56.236] filter004.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta45.mxroute.com (ZoneMTA) with ESMTPSA id 17b3725f98300074ba.002 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Wed, 11 Aug 2021 21:37:20 +0000 X-Zone-Loop: 2388f97178c9253f2606f25dcaba26c89eb8cc231f8e X-Originating-IP: [149.28.56.236] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=x; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=We/du5hu2PUvN+R2Crg4PV9a1cBeRn3qWa7Fdg4U7A8=; b=L3AMbNX++mqYKZp+f2Cg2b/ptF TodJ2W4xctQMFSzg3kv7IjZjSjp0PIHOnhcdTVkw9nGXTTFqsjLf+PPfIzUuHbBx5FG1QEgR8Npuw wo70mk4Kxr0OCL7UTAolLDIsEnRDPJomJ0h8xXbaXzFsMekOq6996PPMjmDzMPgpktJPkDWPtWbUS oVpRLS7s8y7hI8B/9u52vHd1rIlMF4RLJo/ij9OqoOWKxsaOxYwIR/pmUkkaBkLIr3lHksOYH0wSr SAA0PackARz497Z2x6DcQazZYgwOuEKcJdO1/rWtlCQS9g6nTNRQn/aq7Le/vzSQLDBH75IvNxK+3 6nhvwzhw==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [RFC PATCH 05/19] settings: Enable django-cors-headers Date: Wed, 11 Aug 2021 22:36:51 +0100 Message-Id: <20210811213705.36293-6-stephen@that.guru> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811213705.36293-1-stephen@that.guru> References: <20210811213705.36293-1-stephen@that.guru> MIME-Version: 1.0 X-AuthUser: stephen@that.guru X-Zone-Spam-Resolution: no action X-Zone-Spam-Status: No, score=5, required=15, tests=[ARC_NA=0, MID_CONTAINS_FROM=1, FROM_HAS_DN=0, RCPT_COUNT_THREE=0, TO_DN_SOME=0, R_MISSING_CHARSET=2.5, RCVD_COUNT_ZERO=0, FROM_EQ_ENVFROM=0, MIME_TRACE=0, BROKEN_CONTENT_TYPE=1.5, NEURAL_SPAM=0] X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This is proving very useful as I attempt to add some Vue.js components to the frontend. Signed-off-by: Stephen Finucane --- patchwork/settings/dev.py | 26 +++++++++++++++++++++++--- requirements-dev.txt | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git patchwork/settings/dev.py patchwork/settings/dev.py index aa3ee3c5..62ae7004 100644 --- patchwork/settings/dev.py +++ patchwork/settings/dev.py @@ -19,6 +19,11 @@ try: except ImportError: debug_toolbar = None +try: + import corsheaders +except ImportError: + corsheaders = None + # # Core settings # https://docs.djangoproject.com/en/2.2/ref/settings/#core-settings @@ -81,13 +86,13 @@ if debug_toolbar: 'debug_toolbar' ] - DEBUG_TOOLBAR_PATCH_SETTINGS = False - -# This should go first in the middleware classes + # This should go as high as possible in the middleware classes MIDDLEWARE = [ 'debug_toolbar.middleware.DebugToolbarMiddleware', ] + MIDDLEWARE + DEBUG_TOOLBAR_PATCH_SETTINGS = False + INTERNAL_IPS = [ '127.0.0.1', '::1', '172.18.0.1' @@ -102,6 +107,21 @@ if dbbackup: DBBACKUP_STORAGE_OPTIONS = {'location': '.backups'} +# django-cors-headers + +if corsheaders: + INSTALLED_APPS += [ + 'corsheaders', + ] + + # This should go as high as possible in the middleware classes + MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', + ] + MIDDLEWARE + + CORS_ORIGIN_ALLOW_ALL = True + CORS_EXPOSE_HEADERS = ['Link'] + # # Patchwork settings # diff --git requirements-dev.txt requirements-dev.txt index d58dfaa9..229ed0c2 100644 --- requirements-dev.txt +++ requirements-dev.txt @@ -3,4 +3,5 @@ djangorestframework~=3.12.0 django-filter~=2.4.0 django-debug-toolbar~=3.2.0 django-dbbackup~=3.3.0 +django-cors-headers~=3.2.0 -r requirements-test.txt