Hi Berkan,
I didn't make any CORS configuration on Angular side if i had to where it had to be?
Also, there is another client app which created with Mvc UI also using same gateway and there is not any problem.
website.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: "treva-website"
spec:
selector:
matchLabels:
app: "treva-website"
template:
metadata:
labels:
app: "treva-website"
spec:
containers:
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
name: "treva-website"
ports:
- name: "http"
containerPort: 80
volumeMounts:
- name: config-volume
mountPath: /usr/share/nginx/html/dynamic-env.json
subPath: dynamic-env.json
volumes:
- name: config-volume
configMap:
name: treva-website-configmap
**website-configmap.yaml**:
apiVersion: v1
kind: ConfigMap
metadata:
name: "treva-website-configmap"
data:
dynamic-env.json: |-
{
"production": "true",
"application": {
"baseUrl": "https://treva-website.tav.aero",
"name": "Treva",
"logoUrl": ""
},
"localization": {
"defaultResourceName": "Treva"
},
"oAuthConfig": {
"issuer": "https://treva-authserver.tav.aero",
"clientId": "WebSite",
"dummyClientSecret": "1q2w3e*",
"scope": "offline_access openid address email phone profile roles AuthServer AdministrationService AuditLoggingService ChatService ContentManagementService DemoService DocumentManagementService EmailService FileManagementService FormManagementService GdprService IdentityService LanguageService NotificationService SaasService SmsService FastTrackService LoungeService AtuService DutyFreeService SettingService ProfileService OrderService PaymentService",
"requireHttps": "true",
"impersonation": {
"tenantImpersonation": "true",
"userImpersonation": "true"
},
"strictDiscoveryDocumentValidation": "false",
"skipIssuerCheck": "true"
},
"apis": {
"default": {
"url": "https://treva-publicgateway.tav.aero",
"rootNamespace": "TavTechnologies.Treva"
},
"AbpAccountPublic": {
"url": "https://treva-authserver.tav.aero",
"rootNamespace": "AbpAccountPublic"
}
}
}
TrevaPublicGatewayModule:
private static void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{
var corsOrigins = configuration["App:CorsOrigins"];
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
if (!corsOrigins.IsNullOrEmpty())
{
builder
.WithOrigins(
corsOrigins!
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
}
});
});
}
Hello Berkan,
Thank you for your quick response. I already add the "https://treva-website.tav.aero" value to app settings, helm chart values and I can see the CORS values in pod yaml too.
I couldn't find a proper way too understand the real problem.
Dear friends can you help me, please?
PublicGatewayLog: [12:00:35 INF] Request starting HTTP/1.1 OPTIONS http://treva-publicgateway.tav.aero/api/abp/application-configuration?includeLocalizationResources=false - null null [12:00:35 INF] CORS policy execution failed. [12:00:35 INF] Request origin https://treva-website.tav.aero does not have permission to access the resource. [12:00:35 INF] Request finished HTTP/1.1 OPTIONS http://treva-publicgateway.tav.aero/api/abp/application-configuration?includeLocalizationResources=false - 204 null null 0.2578ms
Angular docker file: FROM node:22.13-alpine as builder WORKDIR /src
COPY . . WORKDIR /src
RUN yarn RUN yarn run build:prod
FROM nginx:alpine as publish
COPY --from=builder /src/dynamic-env.json /usr/share/nginx/html COPY --from=builder /src/nginx.conf /etc/nginx/conf.d/default.conf COPY --from=builder /src/dist/treva /usr/share/nginx/html
environment.ts: import { Environment } from '@abp/ng.core';
const baseUrl = 'http://localhost:4200';
const oAuthConfig = { issuer: 'https://treva-authserver.tav.aero/', // redirectUri: baseUrl, clientId: 'WebSite', // responseType: 'code', dummyClientSecret: '1q2w3e*', scope: 'offline_access openid address email phone profile roles AuthServer AdministrationService GdprService LanguageService ChatService ContentManagementService DocumentManagementService FormManagementService EmailService SmsService NotificationService DemoService FastTrackService LoungeService AtuService DutyFreeService', requireHttps: false, impersonation: { tenantImpersonation: true, userImpersonation: true } };
export const environment = { production: false, application: { baseUrl, name: 'Treva' }, localization: { defaultResourceName: 'Treva' }, oAuthConfig, apis: { default: { url: 'https://treva-publicgateway.tav.aero', rootNamespace: 'TavTechnologies.Treva' }, AbpAccountPublic: { url: oAuthConfig.issuer, rootNamespace: 'AbpAccountPublic' } } } as Environment;
environment.prod.ts: import { Environment } from '@abp/ng.core';
const baseUrl = 'https://treva-website.tav.aero';
const oAuthConfig = { issuer: 'https://treva-authserver.tav.aero/', // redirectUri: baseUrl, clientId: 'WebSite', // responseType: 'code', dummyClientSecret: '1q2w3e*', scope: 'offline_access openid address email phone profile roles AuthServer AdministrationService GdprService LanguageService ChatService ContentManagementService DocumentManagementService FormManagementService EmailService SmsService NotificationService DemoService FastTrackService LoungeService AtuService DutyFreeService', requireHttps: true, impersonation: { tenantImpersonation: true, userImpersonation: true }, strictDiscoveryDocumentValidation: false, skipIssuerCheck: true };
export const environment = { production: true, application: { baseUrl, name: 'Treva', }, localization: { defaultResourceName: 'Treva' }, oAuthConfig, apis: { default: { url: 'https://treva-publicgateway.tav.aero', rootNamespace: 'TavTechnologies.Treva' }, AbpAccountPublic: { url: oAuthConfig.issuer, rootNamespace: 'AbpAccountPublic' } }, remoteEnv: { url: '/getEnvConfig', mergeStrategy: 'overwrite' } } as Environment;
website-configmap.yaml: apiVersion: v1 kind: ConfigMap metadata: name: "treva-website-configmap" data: dynamic-env.json: |- { "production": "true", "application": { "baseUrl": "https://treva-website.tav.aero", "name": "Treva", "logoUrl": "" }, "localization": { "defaultResourceName": "Treva" }, "oAuthConfig": { "issuer": "https://treva-authserver.tav.aero", "clientId": "WebSite", "dummyClientSecret": "1q2w3e*", "scope": "offline_access openid address email phone profile roles AuthServer AdministrationService AuditLoggingService ChatService ContentManagementService DemoService DocumentManagementService EmailService FileManagementService FormManagementService GdprService IdentityService LanguageService NotificationService SaasService SmsService FastTrackService LoungeService AtuService DutyFreeService SettingService ProfileService OrderService PaymentService", "requireHttps": "true", "impersonation": { "tenantImpersonation": "true", "userImpersonation": "true" }, "strictDiscoveryDocumentValidation": "false", "skipIssuerCheck": "true" }, "apis": { "default": { "url": "https://treva-publicgateway.tav.aero", "rootNamespace": "TavTechnologies.Treva" }, "AbpAccountPublic": { "url": "https://treva-authserver.tav.aero", "rootNamespace": "AbpAccountPublic" } } }