# Keycloak authentication fails when initiating call with www prefix

**URL:** <https://forum.keycloak.org/t/keycloak-authentication-fails-when-initiating-call-with-www-prefix/5070>\
**Category:** Configuring the server\
**Tags:** adapter-javascript, authentication, client-configuration, oidc\
**Created:** [September 26, 2020, 11:14pm UTC](https://forum.keycloak.org/t/keycloak-authentication-fails-when-initiating-call-with-www-prefix/5070 "2020-09-26T23:14:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![d.lmnn](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@d.lmnn](https://forum.keycloak.org/u/d.lmnn)\
**Post date:** [September 26, 2020, 11:14pm UTC](https://forum.keycloak.org/t/keycloak-authentication-fails-when-initiating-call-with-www-prefix/5070/1 "2020-09-26T23:14:07Z")

</div>

Our web application uses Keycloak 11.0.2 with the appropriate java script adapter. Keycloak and the web application are deployed as single instance in a k8s environment using the kong ingress controller (and api gateway).

Everything works fine when a browser hits the platform url [https://myapplicationurl.com](https://myapplicationurl.com). A user can self register, login to the target application etc. via Keycloak.

However, when “www” is prefixed in the URL (https:// **www**.myapplicationurl.com), submitting the credentials on the Keycloak login form leads to the following error.

> We are sorry… An error occurred, please login again through your application

The corresponding error log in the Keycloak console is:

```
18:05:21,330 WARN [org.keycloak.events] (default task-20) type=LOGIN_ERROR, realmId=myrealm, clientId=null, userId=null, ipAddress=xxx.xxx.xxx.xxx, error=invalid_code

```

The “valid redirect urls” have been set to

```
https://myapplicationurl.com
https://www.myapplicationurl.com

```

The Keycloak adapter is configured to use relative paths by skipping the “url” parameter

```auto
class KeycloakConfig implements Keycloak.KeycloakConfig {
  clientId: string = 'myclient';
  realm: string = 'myrealm';
  url: string = '/auth';
}

```

I tried different browsers on macOs and iOS without success.

What do I miss here?

Thank you!

---

<div class="post-metadata">

**Author:** ![d.lmnn](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@d.lmnn](https://forum.keycloak.org/u/d.lmnn)\
**Post date:** [October 2, 2020, 6:32pm UTC](https://forum.keycloak.org/t/keycloak-authentication-fails-when-initiating-call-with-www-prefix/5070/2 "2020-10-02T18:32:17Z")

</div>

I fixed it with a workaround in the API gateway redirecting the https:// **www**.my… request to [https://my](https://my)…
