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

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

@ -1,4 +1,5 @@
Django==5.2.7 Django==5.2.7
django-cors-headers
aiohttp aiohttp
requests requests
pytz 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! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True 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 # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'corsheaders',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
@ -42,6 +56,7 @@ INSTALLED_APPS = [
] ]
MIDDLEWARE = [ MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',

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

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

@ -5,29 +5,6 @@ import react from '@vitejs/plugin-react'
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
server: { server: {
port: 5173, allowedHosts: ['shop.softwarrior.ru'],
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', '')
)
})
},
},
},
}, },
}) })

Loading…
Cancel
Save