[keycloak-user] JavaScript error: No Access-Control-Allow-Origin header is present...

Lars Frauenrath lars.frauenrath at traveltainment.de
Tue Jul 28 05:30:12 EDT 2015


Hi,

I could resolve my problem. The error occurred because I used a local copy of the keycloak.js file.
Since I am using the file from the server (src =http://localhost:8180/auth/js/keycloak.js) it works fine.

Best regards,
Lars

Von: keycloak-user-bounces at lists.jboss.org [mailto:keycloak-user-bounces at lists.jboss.org] Im Auftrag von Lars Frauenrath
Gesendet: Dienstag, 28. Juli 2015 11:18
An: keycloak-user at lists.jboss.org
Betreff: [keycloak-user] JavaScript error: No Access-Control-Allow-Origin header is present...

Hi,

as the subject said I got an error while sending a request to my keycloak server.
I configured the following things:

1.       External Keycloak server (runs on localhost:8180)

a.       Add realm

b.      Add client/application

c.       Add roles

d.      Add user + roles for this user

e.      Add Url to Web Origins (http://localhost:8080)

2.       Wildfly 8 Server (runs on localhost:8080)

a.       Add keycloak adapter for wilrdfly 8

b.      Add Security domain

c.       Add subsystem for keycloak (generated from keycloak admin console)

3.       My Application

a.       Keycloak.json (generated from Keycloak admin console | "enable-cors" is set to true)

b.      Downloaded keycloak.js and added it to jsp/html pages

c.       Defined security-constraints and security-roles in web.xml

I got the problem while trying to login to my application. Keycloak accepts my username and password and forwards me to the first site of my application.
There I am using the keycloak.js to "login" and handle the different roles but within this workflow I got the following errors:


1.       "XMLHttpRequest cannot load 'http://localhost:8180/auth/realms/TOMAMappingConfigurationService/tokens/access/codes'. No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 400. "

2.       "XMLHttpRequest cannot load 'http://localhost:8180/auth/realms/TOMAMappingConfigurationService/account'. No 'Access-Control-Allow-Origin' header is present on the requested resource.

Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 403. "

I hope you can help me.

Kind regards,
Lars


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20150728/44a5bfff/attachment-0001.html 


More information about the keycloak-user mailing list