настройки публикации

main
Пилипенко Андрей Борисович 1 month ago
parent 39fcf39d71
commit 1ad57d16c3

@ -1,4 +1,5 @@
Django==5.2.7
django-cors-headers
aiohttp
requests
pytz

@ -26,12 +26,26 @@ SECRET_KEY = 'django-insecure-=cldztbc4jg&xl0!x673!*v2_=p$$eu)=7*f#d0#zs$44xx-h^
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '192.168.1.100', 'shop.softwarrior.ru']
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '192.168.1.100', 'shop-api.softwarrior.ru', 'shop.softwarrior.ru']
CORS_ALLOWED_ORIGINS = [
"https://shop.softwarrior.ru",
"https://shop-api.softwarrior.ru",
"http://localhost:5173",
"http://127.0.0.1:5173",
]
CSRF_TRUSTED_ORIGINS = [
"https://shop.softwarrior.ru",
"https://shop-api.softwarrior.ru",
"http://localhost:5173",
"http://127.0.0.1:5173",
]
# Application definition
INSTALLED_APPS = [
'corsheaders',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -42,6 +56,7 @@ INSTALLED_APPS = [
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',

@ -3,12 +3,13 @@ version: '3.8'
services:
frontend:
platform: linux/arm64/v8
image: firstsoftwarrior/shop-frontend
build:
context: frontend
target: development
container_name: firstsoftwarrior-shop-frontend
ports:
- "8090:8090"
- '8090:8090'
environment:
- NODE_ENV=development
volumes:
@ -19,6 +20,7 @@ services:
backend:
platform: linux/arm64/v8
image: firstsoftwarrior/shop-backend
build:
context: backend
target: builder
@ -27,7 +29,6 @@ services:
- '8091:8091'
environment:
- DEBUG=True
- ALLOWED_HOSTS=localhost,127.0.0.1,192.168.1.100,backend,shop.softwarrior.ru
volumes:
- ./backend:/backend

@ -1,7 +1,11 @@
import { token } from './utils'
const DEV_URL = '/dev_api'
const PROD_URL = 'https://shop.softwarrior.ru:8091'
const DEV_URL = 'http://localhost:8091'
const PROD_URL = 'https://shop-api.softwarrior.ru'
const isDEV_HOST =
(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') &&
window.location.port === '5173'
export type ResponseData = {
error?: string
@ -25,7 +29,7 @@ class Network implements NetworkApi {
private _headers: HeaderType
constructor() {
if (import.meta.env.DEV) {
if (import.meta.env.DEV && isDEV_HOST) {
this._baseUrl = DEV_URL
} else {
this._baseUrl = PROD_URL

@ -5,29 +5,6 @@ import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 5173,
proxy: {
'/dev_api': {
target: 'http://localhost:8091',
changeOrigin: true,
secure: false,
rewrite: path => path.replace(/^\/dev_api/, ''),
configure: (proxy, _options) => {
proxy.on('error', (err, _req, _res) => {
console.log('Proxy error:', err)
})
proxy.on('proxyReq', (proxyReq, req, _res) => {
console.log(
proxyReq,
'Proxying:',
req.method,
req.url,
'→',
'http://localhost:8091' + req?.url?.replace('/dev_api', '')
)
})
},
},
},
allowedHosts: ['shop.softwarrior.ru'],
},
})

Loading…
Cancel
Save