Invalid_token on docker an error occurred while attempting to decode the Jwt: Invalid token

I have a backend resource server secured with keycloak
and a React front end application using keycloak javascript adapter
I have successfully obtained an access token in the front end to use it when accessing backend protected services.
when i call a backend service using the access token i get 401 Unauthorized error.
indicating
WWW-Authenticate Bearer error=“invalid_token”, error_description=“An error occurred while attempting to decode the Jwt: Invalid token”,
I have this problem on my docker environment,
If i run the application without using docker i can access the backend service successfully.
I had previously a connection refused error with docker which i resolve it by setting server_name=host.docker.internal
Do anyone have an idea of what could be the problem this time?

Thank you in advance for your help.

You can see the error in the screenshot below:

I had the same problem with a Java Spring Backend, after a lot of google searches, I found out that there were incompatibilities between Signature Algorithm used by spring boot and keycloak.

As part of the initiation I specified SignatureAlgorithm.RS256 in the application and also ensured that same algorithm was used for the realm/client.

I really dont know the specifics on how to use keycloak with nodejs, but for Java Spring I created a @Bean in the WebSecurity class as follows

@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class WebSecurityConfig {
@Value(“${spring.security.oauth2.resourceserver.jwt.jwk-set-uri}”)
private String jwkSetUri;

@Bean
public JwtDecoder jwtDecoder() {
return NimbusJwtDecoder.withJwkSetUri(jwkSetUri).jwsAlgorithm(SignatureAlgorithm.RS256).build();
}
}