How to fix CROS issue on N1QL GET query?

Hi There,

I have been facing issue with CROS on GET N1QL in Jquery. this is working in POST man and other tools. when i parse it by using Jquery. im getting CROS issue. Please assist me how to solve it.

Following is my config file.

{
	log: [
		"*"
	],
	CORS: {
		origin: [
			"*"
		],
		loginOrigin: [
			"http://localhost:8080"
		],
		headers: [
			"Content-Type"
		],
		maxAge: 1728000
	},
	databases: {
		db: {
			server: "http://myappdemo.com:8091/",
			bucket: "default",
			users: {
				GUEST: {
					disabled: false,
					admin_channels: [
						"*"
					]
				}
			}
		}
	}
}

Hi @itssrinadh,
looks like CORS setup issue (not N1QL issue as such). Can you provide details of the setup, and exactly what you are trying to do. Btw, is it sync-gateway config file??

Hi @prasad, Thanks for your reply.

Yes, i was shared sync-gateway config file. I am getting following error on 8093 N1QL port.
Access-Control-Allow-Origin (CORS origin) Issue

Note: It’s working in POSTMAN but not web JQuery.

Here is my code snippet.

$.ajax({
type: “GET”,
url: “http://myserverurl:8093/query/service?statement=select * from default d where accountNumber = ‘123451’ AND documentType = ‘UserModel’ limit 10”,
contentType: “application/json”,

      success: function(response){
        alert("response:"+JSON.stringify(response))
      
       
      }
    })