fabiocicerchia / nginx-lua

Latest Nginx with LUA support based on AlmaLinux, Alpine Linux, Amazon Linux, Debian, Fedora, and Ubuntu.
https://hub.docker.com/r/fabiocicerchia/nginx-lua
Other
191 stars 42 forks source link

How to use cors mudule? #145

Open erickskrauch opened 2 months ago

erickskrauch commented 2 months ago
local cors = require('lib.resty.cors');

Ends with:

[error] 1#1: init_by_lua error: init_by_lua(conf.d/app.conf:8):2: module 'lib.resty.cors' not found:
       no field package.preload['lib.resty.cors']
       no file './lib/resty/cors.lua'
       no file '/usr/local/share/luajit-2.1/lib/resty/cors.lua'
       no file '/usr/local/share/lua/5.1/lib/resty/cors.lua'
       no file '/usr/local/share/lua/5.1/lib/resty/cors/init.lua'
       no file './lib/resty/cors.so'
       no file '/usr/local/lib/lua/5.1/lib/resty/cors.so'
       no file '/usr/local/lib/lua/5.1/loadall.so'
       no file './lib.so'
       no file '/usr/local/lib/lua/5.1/lib.so'
       no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
       [C]: in function 'require'
       init_by_lua(conf.d/app.conf:8):2: in main chunk
[error] init_by_lua error: init_by_lua(conf.d/app.conf:8):2: module 'lib.resty.cors' not found:
       no field package.preload['lib.resty.cors']
       no file './lib/resty/cors.lua'
       no file '/usr/local/share/luajit-2.1/lib/resty/cors.lua'
       no file '/usr/local/share/lua/5.1/lib/resty/cors.lua'
       no file '/usr/local/share/lua/5.1/lib/resty/cors/init.lua'
       no file './lib/resty/cors.so'
       no file '/usr/local/lib/lua/5.1/lib/resty/cors.so'
       no file '/usr/local/lib/lua/5.1/loadall.so'
       no file './lib.so'
       no file '/usr/local/lib/lua/5.1/lib.so'
       no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
       [C]: in function 'require'
       init_by_lua(conf.d/app.conf:8):2: in main chunk
fabiocicerchia commented 2 months ago

Hi @erickskrauch, thank you for raising the issue. The cors library (https://github.com/detailyang/lua-resty-cors) is not currently available, it requires some work to bundle it into the project.