Skip to content

Commit

Permalink
Add files for Vercel deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
davevad93 authored Nov 29, 2024
1 parent 5471bf6 commit aa1a069
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
5 changes: 0 additions & 5 deletions myproject/myapp/static/js/languages.js

This file was deleted.

26 changes: 9 additions & 17 deletions myproject/myproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

STATICFILES_DIRS = [
BASE_DIR / 'myapp' / 'static',
]
STATICFILES_DIRS = [BASE_DIR / 'myapp' / 'static']
STATIC_ROOT = BASE_DIR / 'staticfiles_build'

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
Expand All @@ -30,21 +28,17 @@
SECRET_KEY = os.environ.get('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']
DEBUG = False
ALLOWED_HOSTS = ['.vercel.app', '.now.sh']

# X-Content-Type-Options

SECURE_BROWSER_XSS_FILTER = True

SECURE_HSTS_SECONDS = 31536000

SECURE_HSTS_INCLUDE_SUBDOMAINS = True

SECURE_HSTS_PRELOAD = True

SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_SSL_REDIRECT = True

# Application definition

Expand Down Expand Up @@ -98,10 +92,10 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
}

# Password validation
Expand All @@ -126,9 +120,7 @@
# https://docs.djangoproject.com/en/5.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_TZ = True

# Static files (CSS, JavaScript, Images)
Expand Down
2 changes: 2 additions & 0 deletions myproject/myproject/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')

application = get_wsgi_application()

app = application
26 changes: 26 additions & 0 deletions myproject/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"builds": [
{
"src": "myproject/wsgi.py",
"use": "@vercel/python",
"config": { "maxLambdaSize": "15mb", "runtime": "python3.12" }
},
{
"src": "build_files.sh",
"use": "@vercel/static-build",
"config": {
"distDir": "staticfiles_build"
}
}
],
"routes": [
{
"src": "/static/(.*)",
"dest": "/static/$1"
},
{
"src": "/(.*)",
"dest": "myproject/wsgi.py"
}
]
}

0 comments on commit aa1a069

Please sign in to comment.