tag(修复):修复跨域错误
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
.gradle
|
||||
build
|
||||
build/*
|
||||
!build/install/
|
||||
!build/install/**
|
||||
.env
|
||||
*.iml
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
FROM eclipse-temurin:21-jdk AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY gradlew gradlew
|
||||
COPY gradle gradle
|
||||
COPY build.gradle.kts settings.gradle.kts gradle.properties ./
|
||||
RUN chmod +x gradlew
|
||||
RUN ./gradlew dependencies --no-daemon
|
||||
|
||||
COPY src src
|
||||
RUN ./gradlew installDist --no-daemon
|
||||
|
||||
FROM eclipse-temurin:21-jre
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/build/install/ScreenShareApi ./
|
||||
|
||||
# package-release.sh creates this distribution before building the image.
|
||||
COPY build/install/ScreenShareApi ./
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["./bin/ScreenShareApi"]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
networkTimeout=120000
|
||||
retries=3
|
||||
retryBackOffMs=1000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -34,14 +34,17 @@ fun Application.configureRouting() {
|
||||
}
|
||||
}
|
||||
install(CORS) {
|
||||
val configuredOrigins = this@configureRouting.environment.config
|
||||
.propertyOrNull("cors.allowedOrigins")
|
||||
?.getString()
|
||||
?.split(",")
|
||||
val configuredOrigins = (
|
||||
this@configureRouting.environment.config.propertyOrNull("cors.allowedOrigins")
|
||||
?.getString()
|
||||
?: System.getenv("CORS_ALLOWED_ORIGINS")
|
||||
?: "http://localhost:5173"
|
||||
)
|
||||
.split(",")
|
||||
?.map(String::trim)
|
||||
?.filter(String::isNotEmpty)
|
||||
.orEmpty()
|
||||
configuredOrigins.ifEmpty { listOf("http://localhost:5173") }.forEach { origin ->
|
||||
configuredOrigins.forEach { origin ->
|
||||
allowHost(
|
||||
host = origin.removePrefix("http://").removePrefix("https://"),
|
||||
schemes = listOf(if (origin.startsWith("https://")) "https" else "http"),
|
||||
|
||||
@@ -3,7 +3,6 @@ package top.OrangeRoll
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.testing.testApplication
|
||||
import configureRouting
|
||||
import kotlin.test.*
|
||||
|
||||
class ServerTest {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
node_modules
|
||||
dist
|
||||
.env
|
||||
npm-debug.log*
|
||||
@@ -1,13 +0,0 @@
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:1.27-alpine
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
@@ -1,20 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://api:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user