cancel
Showing results for 
Search instead for 
Did you mean: 

Service Layer CORS header 'Access-Control

former_member260921
Participant
0 Kudos

Hi,

I am using an ajax call to log in to the B1 Service Layer.

The service layer is receiving the login - request. I can see it in the log.

However the ajax call fails with the error: "Cross-Origin request Blocked: The same origin policy disallows ...........(Reason: CORS header 'Access-Control-Allow-Origin' missing).

Is there an easy way to fix this?

Thanks for any help.

Mel

Accepted Solutions (1)

Accepted Solutions (1)

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mel,

Have you configured Service Layer to allow CORS?

There is a section in the Service Layer User Manual talking about it: 3.18 Cross Origin Resource Sharing (CORS) .

"CorsEnable": true,

"CorsAllowedOrigins": "http://pvgd50839753a:8080;http://pvgd50839753a:8443"

And also a blog: https://blogs.sap.com/2015/09/01/b1-service-layer-how-to-enable-cors/

Hope it helps,
Trinidad.

former_member260921
Participant
0 Kudos

Hi Trinidad,

Thank you for your reply,

I have configured the Service Layer as you indicated:

"CorsEnable": true,

"CorsAllowedOrigins": "http://pvgd50839753a:8080;http://pvgd50839753a:8443"

I also added from the documentation:

"CorsAllowedHeaders":"content-type, accept, B1S-CaseInsensitive"

I restarted the service layer and am getting the error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://hanab1vm2:50000/b1s/v1/Login. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I am wondering if "http://pvgd50839753a:8080;http://pvgd50839753a:8443" should be something different for my system. The service layer url on my internal network is https://hanab1vm2:50000/b1s/v1/.

I tried

"http://hanab2vm2:8080;http://hanab2vm2:8443"

and

"http://hanab2vm2:50000;http://hanab2vm2:50001"

I am still stuck. Do you have any other suggestions?

Thanks,

Mel

former_member260921
Participant
0 Kudos

Also I tried this and it failed:

"CorsAllowedOrigins": "*"

Answers (2)

Answers (2)

former_member260921
Participant
0 Kudos

What should be the ip and port allowed as origin?

I have tried many options including the asterisk which should allow all.

"CorsAllowedOrigins": "*"

The inital web page url is http://hanab1vm2:8000/tests/Mel2/webapp/index.html.

Does this mean I have to allow http://hanab1vm2:8000? What port?

Thanks

Eneveux
Product and Topic Expert
Product and Topic Expert
0 Kudos

Mel,

Please see SAP Note 2415097 - Service Layer Error After Upgrade ... not sure what version of SAP B1 for SAP HANA you are using but this may help. Also try using the IP of your machine instead of the qualified name. The machines in the example Trinidad gave you are SAP machines ... so you will definitely get errors with those. If you still run into issues you may want to open a message with SAP Support as the information Trinidad gave is the solution to this type of problem.

Eddy