I'm using Spring Security REST Api with grails and AngularJS. And I tried the url request with postman and it is working fine. It is returning results back with used x-auth-token. But the same i tried with AngularJs but it not going further that OPTION request.


in 1st image here it shows that my request is being processed up to OPTION request only.
in 2nd image, shows what I tried in POSTMAN. It gives the results and works fine with x-auth-token.
in 3rd image, I have integrated spring security plugin as following. And it is working for "api/login" but further it fails.
the 4th image shows the detail response for OPTION request and then it fails to go further.

I have written grunt connect method as following
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
proxies: [
{
context: '/crm/api',
host: 'localhost',
port: 8080
}
],
livereload: {
options: {
open: true,
base: [
'.tmp',
'<%= yeoman.app %>'
]
}
},
test: {
options: {
port: 9001,
base: [
'.tmp',
'test',
'<%= yeoman.app %>'
]
}
},
dist: {
options: {
base: '<%= yeoman.dist %>'
}
}
}
Still I have the same error.
This is a cross-domain issue.
Your webpage is on localhost:9000 and your backend is localhost:8080. These are technically 2 different domains, so you will need to either enable cross origin requests, or use a proxy to make requests forward to port 8080.
It looks like you're using grunt, so I would suggest setting up the proxy. I use grunt-connect-proxy to setup forwarding to my backend port:
connect: {
options: {
port: 9000,
hostname: 'localhost',
livereload: 35729
},
proxies: [
{
context: '/crm/api',
host: 'localhost',
port: 8080
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With