First I would like to thank Amm0 for your kind contribution.
I didn't make the proxy running inside the Mikrotik unit. However, I still used nginx and proxy_pass stuff exactly the same.
One problem I came across was when sending PUT request to add in new firewall address-list.
I got an error complaining CORS.
Mind you, GET had no problem. I haven't played with anything else, so no idea if DELETE, PATCH or whatever worked or not.
May be this is a thing with firewall address-list? I don't know. My only need was for firewall address-list so ... anyway.
What I did to get around it was, add another line of add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS' always; inside the if ($request_method = 'OPTIONS') if code block.
So the final would look like below,I'm not sure why that is needed but putting there fixed it at least.
Just thought I'd let you know incase you might want to tackle this problem differently.
I didn't make the proxy running inside the Mikrotik unit. However, I still used nginx and proxy_pass stuff exactly the same.
One problem I came across was when sending PUT request to add in new firewall address-list.
I got an error complaining CORS.
Mind you, GET had no problem. I haven't played with anything else, so no idea if DELETE, PATCH or whatever worked or not.
May be this is a thing with firewall address-list? I don't know. My only need was for firewall address-list so ... anyway.
What I did to get around it was, add another line of add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS' always; inside the if ($request_method = 'OPTIONS') if code block.
So the final would look like below,
Code:
if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; }
Just thought I'd let you know incase you might want to tackle this problem differently.
Statistics: Posted by giguard — Mon Feb 12, 2024 9:27 am