We need to set the `Access-Control-Allow-Origin` header in order to upload gcode with XHR
31 lines
1.2 KiB
Nix
31 lines
1.2 KiB
Nix
{ pkgs, ... }:
|
|
|
|
{
|
|
services.nginx.virtualHosts."upload.laserkutter.lab.fablab-nea.de" = {
|
|
root = pkgs.fablab.laser-upload;
|
|
};
|
|
services.nginx.virtualHosts."proxy.laserkutter.lab.fablab-nea.de" = {
|
|
# "/rr_upload"
|
|
#basicAuthFile =
|
|
# Basic Auth password file for a vhost. Can be created via: htpasswd -c <filename> <username>. WARNING: The generate file contains the users' passwords in a non-cryptographically-securely hashed way.
|
|
extraConfig = ''
|
|
set $duet_web "laserkutter.lab.fablab-nea.de";
|
|
allow 192.168.94.0/24;
|
|
deny all;
|
|
location / {
|
|
if ($request_method = OPTIONS ) {
|
|
add_header 'Access-Control-Allow-Origin' 'http://upload.laserkutter.lab.fablab-nea.de';
|
|
add_header 'Access-Control-Allow-Methods' 'POST';
|
|
add_header 'Access-Control-Allow-Headers' 'Content-Type';
|
|
add_header 'Content-Type' 'text/plain charset=UTF-8';
|
|
add_header 'Content-Length' 0;
|
|
return 204;
|
|
break;
|
|
}
|
|
add_header 'Access-Control-Allow-Origin' 'http://upload.laserkutter.lab.fablab-nea.de';
|
|
proxy_set_header Origin "http://$duet_web";
|
|
proxy_pass "http://$duet_web";
|
|
}
|
|
'';
|
|
};
|
|
}
|