0

I created a simple jhipster file with microfrontend:

application {
  config {
    baseName testgateway
    applicationType gateway
    packageName com.example
    authenticationType jwt
    prodDatabaseType postgresql
    serviceDiscoveryType consul
    clientFramework react
    microfrontends [testms]
  }
}

application {
  config {
    baseName testms
    applicationType microservice
    packageName com.example
    authenticationType jwt
    prodDatabaseType postgresql
    serviceDiscoveryType consul
    serverPort 8081
    clientFramework react
  }
  entities TestE
}


deployment {
  deploymentType docker-compose
  serviceDiscoveryType consul
  appsFolders [testgateway, testms]
}

entity TestE{
  name String
}

When I deploy it to my local docker with the created docker-compose.yml file it doesn't work properly. When I access anything user-related through the gateway frontend (register, create user, change password,... - strangely enough I actually can log in) I get an error message with "an unexpected error occured". The logs in the gateway report o.z.problem.spring.common.AdviceTraits : Unauthorized: Not Authenticated. When selecting Health, Logs, or anything else under the Administration navigation (except API-Documentation, which works fine) I get an empty response, no error though. I also can access the endpoints of the microservice through the gateway. It seems that all endpoints of the gateway are blocked when trying to reach them through the UI/react. When im executing a GET-Request through Postman it works fine and I can get for example all users or can access /api/accounts. The log of my browser says, that the request to the same endpoint is unauthorized. It seems that the Frontend doesn't send the JWT-Token in that case.

I'm using MacBook Pro with M1 Pro Chip and Ventura 13.2.1 Node 18.15.0

JDK 11.0.18

Jhipster 7.9.3

Docker 20.10.23, build 7155243

My steps were:

jhipster jdl jhipster.jdl

Running ./mvnw -ntp -Pprod verify jib:dockerBuild in both folders

Running docker-compose up -d in docker-compose folder

I tried to use different node versions (16,19). With 16 it didn't work at all and with 19 I had the same errors. People I know tried it on Windows and Linux and it was working fine. I also configured Spring Boot to permit all requests, which was also not working.

Would be nice if anyone can help :)

1 Answers1

0

I am assuming that your JWT secrets are not the same. Have a look inside of your application*.yml files. It is important to know which application*.yml file are used at runtime. You can make use of spring-cloud-config to use a centralized approach. This question is a similar problem and show also an option for using the JHipter-Registry JWT authentication of jhipster application

duderoot
  • 977
  • 1
  • 8
  • 23
  • I tried, but it didn't work. Also I'm using consul, so they should share the secret, shouldn't they? It seems that there is a problem with react. I generated the same application but with angular instead of react and it worked (even though I had different problems which I was able to fix though). – Jonathan M. Apr 03 '23 at 06:47