Closed manisi closed 1 year ago
Are you sure you added CORS information in the correct part of application.yml
? You might look at the application-dev.yml
template to see where it should be.
Yes, please pay attention to this screenshot
I believe I found the issue. Can you try adding .cors(withDefaults())
to your SecurityConfiguration
class. Like this:
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.cors(withDefaults())
This solves the problem for me. If it does for you, too, I'll create a PR to update JHipster.
Looks like the problem still exists.
Can you please share the output from jhipster info
in your backend project? I did not test with WebFlux.
yes of course.
Welcome to JHipster v8.0.0-beta.1
Welcome to the JHipster Information Sub-Generator
bahilla-gateway@0.0.1-SNAPSHOT /Users/developer/Desktop/bahillaApp/gateway
└── generator-jhipster@8.0.0-beta.1
.yo-rc.json
file generated in the root folder{ "applicationType": "gateway", "authenticationType": "jwt", "baseName": "bahillaGateway", "buildTool": "maven", "cacheProvider": "hazelcast", "clientFramework": "angular", "clientTheme": "none", "creationTimestamp": 1687544869292, "databaseType": "sql", "devDatabaseType": "mysql", "devServerPort": 4200, "dtoSuffix": "DTO", "enableGradleEnterprise": null, "enableHibernateCache": true, "enableSwaggerCodegen": false, "enableTranslation": true, "entities": [], "entitySuffix": "", "gradleEnterpriseHost": null, "jhiPrefix": "jhi", "jhipsterVersion": "8.0.0-beta.1", "languages": [ "fa", "en", "fr" ], "messageBroker": false, "microfrontend": false, "microfrontends": [], "nativeLanguage": "fa", "packageFolder": "ir/bahilla/gateway", "packageName": "ir.bahilla.gateway", "pages": [], "prodDatabaseType": "mysql", "reactive": true, "searchEngine": false, "serverPort": 8080, "serverSideOptions": [], "serviceDiscoveryType": "consul", "skipCheckLengthOfIdentifier": false, "skipClient": false, "skipFakeData": false, "skipUserManagement": false, "testFrameworks": [], "websocket": false, "withAdminUi": true }
java version "17.0.7" 2023-04-18 LTS Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224) Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)
git version 2.20.1
node: v18.16.1 npm: 9.7.2
@mshima If I copy the .yo-rc.json
file to an empty directory and run jhipster
, it doesn't create the project for me. Instead, it prompts me for the baseName. This is new behavior with v8. Is it expected?
.yo-rc.json
create empty folder and paste yo-rc.json in it and jhipster generate gateway2 thats ok.
I was able to fix it by changing from CorsWebFilter
to CorsConfigurationSource
. Can you try this:
@Bean
public CorsConfigurationSource corsConfigurationSource() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = jHipsterProperties.getCors();
if (!CollectionUtils.isEmpty(config.getAllowedOrigins()) || !CollectionUtils.isEmpty(config.getAllowedOriginPatterns())) {
log.debug("Registering CORS filter");
source.registerCorsConfiguration("/api/**", config);
source.registerCorsConfiguration("/management/**", config);
source.registerCorsConfiguration("/v3/api-docs", config);
source.registerCorsConfiguration("/swagger-ui/**", config);
source.registerCorsConfiguration("/*/api/**", config);
source.registerCorsConfiguration("/services/*/api/**", config);
source.registerCorsConfiguration("/*/management/**", config);
}
return source;
}
Note that I do get the following error after login because fa
is not in the Ionic blueprint's languages.
GET http://localhost:8100/assets/i18n/fa.json 404 (Not Found)
You can see the list of languages at https://github.com/jhipster/generator-jhipster-ionic/tree/main/generators/ionic/resources/base/src/assets/i18n.
fixed . thank to you. @mraible
Hello Matt, using jhipster 8 beta gateway app run on docker and generate ionic app with generate-jhppster-ionic(jhipster 7.9.3) and set cors origin in application.yaml (http://localhost:8100) but this error exists before and after login . but signup and authenticate is ok . for /api/account ::: [Error] XMLHttpRequest cannot load http://localhost:8080/api/account due to access control checks. [Error] Failed to load resource: Origin http://localhost:8100 is not allowed by Access-Control-Allow-Origin. Status code: 401 (account, line 0)
thanks alot