Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

best cors options for express app

// In Nginx
map $http_origin $allow_origin {
    ~^https?://(.*.)?my-domain.com(:d+)?$ $http_origin;
    ~^https?://(.*.)?localhost(:d+)?$ $http_origin;
    default "";
}

server {
    listen 80 default_server;
    server_name _;
    add_header 'Access-Control-Allow-Origin' $allow_origin;
    # ...
}
Source by expressjs.com #
 
PREVIOUS NEXT
Tagged: #cors #options #express #app
ADD COMMENT
Topic
Name
8+8 =