Fron-back work together

This commit is contained in:
Max 2025-01-25 23:22:48 +03:00
parent 0ddb70fc36
commit 135546b3c8
5 changed files with 26 additions and 4 deletions

View File

@ -1,4 +1,5 @@
services:
nginx:
build: ./enshi
ports:
@ -8,6 +9,14 @@ services:
- app-network
restart: unless-stopped
enshi_back:
build: ./enshi_back
ports:
- 127.0.0.1:9876:9876
networks:
- app-network
restart: unless-stopped
networks:
app-network:
driver: bridge

View File

@ -7,7 +7,8 @@ server {
server {
listen 443 ssl http2;
server_name nekiiinkognito.ru www.nekiiinkognito.ru;
# server_name nekiiinkognito.ru www.nekiiinkognito.ru;
server_name localhost;
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
@ -29,7 +30,7 @@ server {
}
location /api/v1/ {
proxy_pass http://127.0.0.1:9876/;
proxy_pass http://enshi_back:9876/;
}
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

View File

@ -2,7 +2,7 @@ import axios from "axios";
export const axiosLocalhost = axios.create(
{
baseURL: `http://127.0.0.1:9876/`,
baseURL: `https://localhost/api/v1/`,
withCredentials: true,
headers: {

View File

@ -5,4 +5,5 @@ const DomainForCookies = "127.0.0.1"
const SecureForCookies = false
const HttpOnlyForCookies = false
const GinWorkPath = "localhost:9876"
// Change to 0.0.0.0 when docker this
const GinWorkPath = "127.0.0.1:9876"

View File

@ -8,6 +8,9 @@ import (
"enshi/global"
"enshi/routes"
"fmt"
"io"
"log"
"os"
"github.com/gin-gonic/gin"
)
@ -27,6 +30,14 @@ func main() {
defer db_connection.Dbx_connection.Close(context.Background())
router := gin.Default()
f, err := os.OpenFile("gin.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
log.Fatal(err)
}
defer f.Close()
gin.DefaultWriter = io.MultiWriter(f)
if err := routes.SetupRotes(router); err != nil {
fmt.Println(err.Error())
return