Setup Nginx for CORS support (3.x)

Introduction

There are two things to be added for Nginx:

1.CORS support

2.Disable same site enforcement for cookie

Instructions

1.Download the template file in attachment for your corresponding version (3.0.x and 3.1.x+) and put it on your server. For example, put it into:

/home/tigergraph/tmp/nginx.conf.template

2.Update all the "Access-Control-Allow-Origin" values to your client origin and save it. By default, it is "http://localhost:3000"

3.Update the Nginx template:

gadmin config set Nginx.ConfigTemplate @PATH_TO_TEMPLATE
# E.g.
# @/home/tigergraph/tmp/nginx.conf.template

4.Disable same site enforcement for cookie for 3.1 and above:

gadmin config set GUI.Cookie.SameSite 4
If the browser complains that the cookie needs to be secure, you have to enable SSL for it to work. Once SSL is enable, the cookie will be automatically tagged as secure.

5.Disable same site enforcement for cookie for 3.0, add:

proxy_cookie_path / "/; SameSite=none"; # for http
proxy_cookie_path / "/; secure; SameSite=none"; # for https

to block:

location @backend {
  ...
}

6.Apply config:

gadmin config apply -y

7.Restart Nginx:

gadmin restart nginx -y