All Projects → detailyang → lua-resty-cors

detailyang / lua-resty-cors

Licence: MIT license
It's the implement of CORS on OpenResty

Programming Languages

lua
6591 projects
Makefile
30231 projects

Labels

Projects that are alternatives of or similar to lua-resty-cors

realestate
A simple real estate app build with MEAN( Angular, Node and mongoDb ) and MERN( React, Node and mongoDb )
Stars: ✭ 33 (-37.74%)
Mutual labels:  cors
sanic-ext
Extended Sanic functionality
Stars: ✭ 26 (-50.94%)
Mutual labels:  cors
gotify-push
Chrome Extension for Send Push Notification 🔔 to gotify/server ☁
Stars: ✭ 32 (-39.62%)
Mutual labels:  cors
simple-cors
Simply usable CORS middleware / interceptor for Clojure
Stars: ✭ 26 (-50.94%)
Mutual labels:  cors
aws-lambda-router
Improved routing for AWS Lambda like SNS and ApiGateway
Stars: ✭ 90 (+69.81%)
Mutual labels:  cors
Natours
An awesome tour booking web app written in NodeJS, Express, MongoDB 🗽
Stars: ✭ 94 (+77.36%)
Mutual labels:  cors
Bus
Bus 是一个基础框架、服务套件,它基于Java8编写,参考、借鉴了大量已有框架、组件的设计,可以作为后端服务的开发基础中间件。代码简洁,架构清晰,非常适合学习使用。
Stars: ✭ 253 (+377.36%)
Mutual labels:  cors
node-typescript-starter
REST API using Node with typescript, KOA framework. TypeORM for SQL. Middlewares JWT (auth), CORS, Winston Logger, Error, Response
Stars: ✭ 19 (-64.15%)
Mutual labels:  cors
BarterOnly
An ecommerce platform to buy or exchange items at your convenience
Stars: ✭ 16 (-69.81%)
Mutual labels:  cors
keycloak-spring-boot-rest-angular-demo
Demo for configuring Keycloak authentication for a spring-boot rest service and AngularJs web client
Stars: ✭ 24 (-54.72%)
Mutual labels:  cors
upload-file-to-backblaze-b2-from-browser-example
Demonstrates calling the b2_upload_file Backblaze B2 Cloud Storage API from a web browser using AJAX.
Stars: ✭ 28 (-47.17%)
Mutual labels:  cors
CORS-Proxy-Server
代理转发 CORS 跨域资源请求
Stars: ✭ 13 (-75.47%)
Mutual labels:  cors
apollobank
A full stack GraphQL banking application using React, Node & TypeScript.
Stars: ✭ 203 (+283.02%)
Mutual labels:  cors
laravel-cors
Laravel cors
Stars: ✭ 19 (-64.15%)
Mutual labels:  cors
ego
Go微服务.A simple and component-based microservice kit for go.
Stars: ✭ 765 (+1343.4%)
Mutual labels:  resty
drf-starter-template
DRF Starter Template with drf-yasg, heroku deployment ready config, CORS config
Stars: ✭ 25 (-52.83%)
Mutual labels:  cors
aspect
Aspect is a compiling template engine for Lua and LuaJIT
Stars: ✭ 17 (-67.92%)
Mutual labels:  resty
poop
Firefox extension that prevents sending Origin headers when they are least likely to be necessary, to protect your privacy.
Stars: ✭ 36 (-32.08%)
Mutual labels:  cors
laravel-api-boilerplate-passport
An API Boilerplate to create a ready-to-use REST API in seconds.
Stars: ✭ 20 (-62.26%)
Mutual labels:  cors
terraform-aws-api-gateway-enable-cors
Easily add an OPTIONS method to an API Gateway resource to enable CORS
Stars: ✭ 56 (+5.66%)
Mutual labels:  cors

Name

lua-resty-cors

lua-resty-cors

It's the implement of CORS on OpenResty and It backports the nginx-http-cors to OpenResty

Table of Contents

Status

Build Status

Usage

It may be placed on the nginx http block for a global CORS config or in each server block to configure a different CORS for each virtual host as the following:

http {
      init_by_lua_block {
        local cors = require('lib.resty.cors');

        cors.allow_host([==[.*\.google\.com]==])
        cors.allow_host([==[.*\.facebook\.com]==])
        cors.expose_header('x-custom-field1')
        cors.expose_header('x-custom-field2')
        cors.allow_method('GET')
        cors.allow_method('POST')
        cors.allow_method('PUT')
        cors.allow_method('DELETE')
        cors.allow_header('x-custom-field1')
        cors.allow_header('x-custom-field2')
        cors.max_age(7200)
        cors.allow_credentials(false)
      }
      
      header_filter_by_lua_block {
        local cors = require('lib.resty.cors');
        cors.run()
    }
}

API

allow_host

syntax: cors.allow_host(host)

This will match the host from cors request then be added to the header Access-Control-Allow-Origin like as the following:

Request:
Origin: https://www.google.com

Response:
Access-Control-Allow-Origin: http://www.google.com

expose_header

syntax: cors.expose_header(header)

This will be added to the header Access-Control-Expose-Headers like as the following:

Request:
Origin: https://www.google.com

Response:
Access-Control-Expose-Headers: x-custom-field1,x-custom-field2

allow_method

syntax: cors.allow_method(method)

This will be added to the header Access-Control-Allow-Methods like as the following:

Request:
Origin: https://www.google.com

Response:
Access-Control-Allow-Methods:GET,POST,PUT

allow_header

syntax: cors.allow_header(header)

This will be added to the header Access-Control-Allow-Headers like as the following:

Request:
Origin: https://www.google.com

Response:
Access-Control-Allow-Headers:x-custom-field1,x-custom-field2

max_age

syntax: cors.max_age(age)

This will be added to the header Access-Control-Max-Age like as the following:

Request:
Origin: https://www.google.com

Response:
Access-Control-Max-Age: 7200

Allow-Credentials

syntax: cors.allow_credentials(true or false)

This will be added to the header Access-Control-Allow-Credentials like as the following:

Request:
Origin: https://www.google.com

Response:
Access-Control-Allow-Credentials: true

run

syntax: cors.run()

This is the entry for lua-resty-cors to run

Contributing

To contribute to lua-resty-cors, clone this repo locally and commit your code on a separate branch.

PS: PR Welcome 🚀 🚀 🚀 🚀

Author

GitHub @detailyang

License

lua-resty-cors is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].