Azure Web app deploy CORS and 503 problem

I have a web app(react+.net8+azure sqlserver) docker-containerized successfully and run smoothly in local environment.

But CORS problem and 503 error happen after I upload my frontend and backend docker images to azure container and deploy them using azure web app service.

Currently I can access the deployed azure frontend page but when I try to fetch data from backend, the following error happens.

At same time, if I open my deployed azure backend site, following error displayed.

I have set CORS rule at my backend program.cs like:

app.UseCors(x => x
        .AllowAnyMethod()
        .AllowAnyHeader()
        .SetIsOriginAllowed(origin => true) 
        .AllowCredentials());

I added environment variable CORS at azure like:

http://localhost:80,http://localhost,http://frontend,http://"frontendwebappname".azurewebsites.net,https://"frontendwebappname".azurewebsites.net

Also, in API-CORS section, I added allowed origins same as what’s in variables CORS.
And I Enable Access-Control-Allow-Credentials.

I added all environment variables to azure as in my docker-compose.yml file.

  backend:
    container_name: backend
    image: backend
    build:
      context: ./Backend
      dockerfile: Dockerfile
    ports:
      - "80:80"
      - "443:443"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_HTTP_PORTS=80
      - ASPNETCORE_HTTPS_PORTS=443
      - ASPNETCORE_Kestrel__Certificates__Default__Password=xxx
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/app/Certificates.p12
      - ConnectionStrings__ApplicationDbContext=Server=tcp:xxx.database.windows.net,1433;Initial Catalog=xxx;Persist Security Info=False;User ID=xxx;Password=xxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=60;
      - JwtSettings__SecretKey=xxx
      - JwtSettings__Issuer=xxx
      - JwtSettings__Audience=xxx
      - JwtSettings__ExpirationMinutes=xxx
    networks:
      - app-network

For my frontend settings, below are dockerfile and nginx.conf in my frontend folder.

FROM node:latest AS build
WORKDIR /app
COPY package.json ./
COPY package-lock.json ./
RUN npm install
COPY . .

RUN npm run build

# Stage 2: Serve with NGINX
FROM nginx:latest

# Install dnsutils for Debian/Ubuntu
RUN apt-get update && apt-get install -y dnsutils

# Copy NGINX configuration
COPY nginx.conf /etc/nginx/nginx.conf

# Copy built React application
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
# Command to run NGINX
CMD ["nginx", "-g", "daemon off;"]
events {}

http {
    include /etc/nginx/mime.types;

    server {
        listen 80;
        server_name localhost;

        # Location block for serving frontend static files
        location / {
            root /usr/share/nginx/html;
            index index.html index.htm;
            try_files $uri $uri/ /index.html;
        }

        # Proxy HTTP API requests
        location /api/http/ {
            rewrite ^/api/http/(.*)$ /$1 break;
            proxy_pass http://"backendwebappname".azurewebsites.net:80;
            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;
        }

        # Proxy HTTPS API requests
        location /api/https/ {
            rewrite ^/api/https/(.*)$ /$1 break;
            proxy_pass https://"backendwebappname".azurewebsites.net:443;
            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;
        }

    }
}

I also changed my VITE_API_URL as

VITE_API_URL = https://"backendwebappname".azurewebsites.net:443/api

so in docker-compose.yml file, my frontend settings are as below:

  frontend:
    container_name: frontend
    image: frontend
    build:
      context: ./Frontend
      dockerfile: Dockerfile
    ports:
      - "80:80"
    environment:
      - VITE_API_URL=https://"backendwebappname".azurewebsites.net:443/api
    depends_on:
      - backend
    networks:
      - app-network

now I have no idea how to do further debug or fix my code. chatgpt keeps telling me to check my cors setting in program.cs, but it should not be the root cause.
Could anyone give me any advice or hint? Thank you in advance!

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật