Skip to content

Commit 2632909

Browse files
committed
Update Backend Cors
1 parent 70b679a commit 2632909

File tree

22 files changed

+90
-130
lines changed

22 files changed

+90
-130
lines changed

.github/workflows/coding-service-publish.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,8 @@ jobs:
4545
REPO_HUB="${{ secrets.DOCKERHUB_USER }}/codecampus-${{ matrix.module || 'file-service' }}"
4646
REPO_GHCR="ghcr.io/${OWNER_LC}/codecampus-${{ matrix.module || 'file-service' }}"
4747
48-
HUB="${REPO_HUB}:${TAG}"
49-
GHCR="${REPO_GHCR}:${TAG}"
50-
51-
if [ "${GITHUB_REF_TYPE}" = "tag" ] || [ "${GITHUB_REF_NAME}" = "main" ]; then
52-
HUB="${HUB}"$'\n'"${REPO_HUB}:latest"
53-
GHCR="${GHCR}"$'\n'"${REPO_GHCR}:latest"
54-
fi
48+
HUB="${REPO_HUB}:${TAG}"$'\n'"${REPO_HUB}:latest"
49+
GHCR="${REPO_GHCR}:${TAG}"$'\n'"${REPO_GHCR}:latest"
5550
5651
{
5752
echo "tags<<__TAGS__"

.github/workflows/deploy.yml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,9 @@ jobs:
4646

4747
- name: Derive IMAGE_TAG (from workflow_run or manual)
4848
shell: bash
49-
env:
50-
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
51-
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
52-
EVENT_NAME: ${{ github.event_name }}
5349
run: |
54-
set -euo pipefail
55-
IMAGE_TAG_VALUE=""
56-
if [ "${EVENT_NAME}" = "workflow_dispatch" ]; then
57-
IMAGE_TAG_VALUE="latest"
58-
else
59-
if [[ "${HEAD_BRANCH:-}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
60-
IMAGE_TAG_VALUE="${HEAD_BRANCH#v}"
61-
elif [ "${HEAD_BRANCH:-}" = "main" ]; then
62-
IMAGE_TAG_VALUE="latest"
63-
else
64-
IMAGE_TAG_VALUE="${HEAD_SHA:0:12}"
65-
fi
66-
fi
67-
echo "Resolved IMAGE_TAG=${IMAGE_TAG_VALUE}"
68-
echo "IMAGE_TAG=${IMAGE_TAG_VALUE}" >> "$GITHUB_ENV"
50+
echo "Resolved IMAGE_TAG=latest"
51+
echo "IMAGE_TAG=latest" >> "$GITHUB_ENV"
6952
7053
- name: Compute .env SHA256
7154
run: |

.github/workflows/docker-publish.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,9 @@ jobs:
5555
5656
REPO_HUB="${{ secrets.DOCKERHUB_USER }}/codecampus-${{ matrix.module || 'file-service' }}"
5757
REPO_GHCR="ghcr.io/${OWNER_LC}/codecampus-${{ matrix.module || 'file-service' }}"
58-
59-
HUB="${REPO_HUB}:${TAG}"
60-
GHCR="${REPO_GHCR}:${TAG}"
61-
62-
if [ "${GITHUB_REF_TYPE}" = "tag" ] || [ "${GITHUB_REF_NAME}" = "main" ]; then
63-
HUB="${HUB}"$'\n'"${REPO_HUB}:latest"
64-
GHCR="${GHCR}"$'\n'"${REPO_GHCR}:latest"
65-
fi
58+
59+
HUB="${REPO_HUB}:${TAG}"$'\n'"${REPO_HUB}:latest"
60+
GHCR="${REPO_GHCR}:${TAG}"$'\n'"${REPO_GHCR}:latest"
6661
6762
{
6863
echo "tags<<__TAGS__"

.github/workflows/file-service-publish.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,10 @@ jobs:
4444
4545
REPO_HUB="${{ secrets.DOCKERHUB_USER }}/codecampus-${{ matrix.module || 'file-service' }}"
4646
REPO_GHCR="ghcr.io/${OWNER_LC}/codecampus-${{ matrix.module || 'file-service' }}"
47-
48-
HUB="${REPO_HUB}:${TAG}"
49-
GHCR="${REPO_GHCR}:${TAG}"
50-
51-
if [ "${GITHUB_REF_TYPE}" = "tag" ] || [ "${GITHUB_REF_NAME}" = "main" ]; then
52-
HUB="${HUB}"$'\n'"${REPO_HUB}:latest"
53-
GHCR="${GHCR}"$'\n'"${REPO_GHCR}:latest"
54-
fi
55-
47+
48+
HUB="${REPO_HUB}:${TAG}"$'\n'"${REPO_HUB}:latest"
49+
GHCR="${REPO_GHCR}:${TAG}"$'\n'"${REPO_GHCR}:latest"
50+
5651
{
5752
echo "tags<<__TAGS__"
5853
printf '%s\n' "$HUB"

ai-service/src/main/java/com/codecampus/ai/config/SecurityConfig.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import static com.codecampus.ai.constant.config.SecurityConfigConstant.AUTHORIZATION_HEADER;
55
import static com.codecampus.ai.constant.config.SecurityConfigConstant.CONTENT_TYPE_HEADER;
66
import static com.codecampus.ai.constant.config.SecurityConfigConstant.DELETE_METHOD;
7-
import static com.codecampus.ai.constant.config.SecurityConfigConstant.FRONTEND_ENDPOINT;
8-
import static com.codecampus.ai.constant.config.SecurityConfigConstant.FRONTEND_ENDPOINT2;
9-
import static com.codecampus.ai.constant.config.SecurityConfigConstant.FRONTEND_ENDPOINT3;
107
import static com.codecampus.ai.constant.config.SecurityConfigConstant.GET_METHOD;
118
import static com.codecampus.ai.constant.config.SecurityConfigConstant.OPTIONS_METHOD;
129
import static com.codecampus.ai.constant.config.SecurityConfigConstant.PATCH_METHOD;
@@ -111,10 +108,12 @@ public CorsConfigurationSource corsConfigurationSource() {
111108
CorsConfiguration configuration = new CorsConfiguration();
112109

113110
// Cho phép các origin truy cập định nghĩa sẵn
114-
configuration.setAllowedOrigins(
115-
List.of(FRONTEND_ENDPOINT, FRONTEND_ENDPOINT2,
116-
FRONTEND_ENDPOINT3)
117-
);
111+
configuration.setAllowedOriginPatterns(List.of(
112+
"http://3.27.221.69:*", // mọi port HTTP của 3.27.221.69
113+
"https://3.27.221.69:*", // nếu có HTTPS
114+
"http://192.168.1.30:4200",
115+
"http://localhost:4200"
116+
));
118117

119118
// Cho phép các phương thức HTTP được định nghĩa
120119
configuration.setAllowedMethods(

ai-service/src/main/java/com/codecampus/ai/constant/config/SecurityConfigConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class SecurityConfigConstant {
2424
// FRONTEND ENDPOINT
2525
public static final String FRONTEND_ENDPOINT = "http://192.168.1.30:4200";
2626
public static final String FRONTEND_ENDPOINT2 = "http://localhost:4200";
27-
public static final String FRONTEND_ENDPOINT3 = "http://72.60.41.133:4200";
27+
public static final String FRONTEND_ENDPOINT3 = "http://3.27.221.69";
2828

2929
// METHOD ALLOWED
3030
public static String GET_METHOD = "GET";

build-image-coding-github.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ build_push_coding() {
5151
--build-arg "MODULE=${module}" \
5252
--build-arg "DOCKER_HOST_GID=${DOCKER_GID}" \
5353
-t "${repo}:${IMAGE_TAG}" \
54+
-t "${repo}:latest" \
5455
$(extra_tags_args "${repo}") \
5556
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}/$([ -n "${GITHUB_REPOSITORY:-}" ] && echo "${GITHUB_REPOSITORY}")" \
5657
--label "org.opencontainers.image.revision=${GITHUB_SHA:-}" \

build-image-file.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ build_push_file_service() {
3737
--platform "${DOCKER_PLATFORMS}" \
3838
-f docker/file-service.Dockerfile \
3939
-t "${repo}:${IMAGE_TAG}" \
40+
-t "${repo}:latest" \
4041
$(extra_tags_args "${repo}") \
4142
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}/$([ -n "${GITHUB_REPOSITORY:-}" ] && echo "${GITHUB_REPOSITORY}")" \
4243
--label "org.opencontainers.image.revision=${GITHUB_SHA:-}" \

build-image-github.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ build_push_java() {
4646
-f docker/java-service.Dockerfile \
4747
--build-arg "MODULE=${module}" \
4848
-t "${repo}:${IMAGE_TAG}" \
49+
-t "${repo}:latest" \
4950
$(extra_tags_args "${repo}") \
5051
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}/$([ -n "${GITHUB_REPOSITORY:-}" ] && echo "${GITHUB_REPOSITORY}")" \
5152
--label "org.opencontainers.image.revision=${GITHUB_SHA:-}" \

build-image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ build_push_java() {
1717
-f docker/java-service.Dockerfile \
1818
"${build_args[@]}" \
1919
-t "$DOCKERHUB_USER/codecampus-$module:$IMAGE_TAG" \
20+
-t "$DOCKERHUB_USER/codecampus-$module:latest" \
2021
--push .
2122
}
2223

0 commit comments

Comments
 (0)