add cors headers, explicit local host for proxy
This commit is contained in:
parent
3ef4afbcf8
commit
5ef41da651
3 changed files with 4 additions and 3 deletions
2
app.js
2
app.js
|
|
@ -516,7 +516,7 @@ function ifModifiedDate(req) {
|
|||
|
||||
function addCorsHeaders(req, res) {
|
||||
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
||||
res.setHeader('Access-Control-Allow-Headers', 'X-Moto-Ajax, Content-Type');
|
||||
res.setHeader('Access-Control-Allow-Headers', 'X-Api-Key, X-Host, X-Moto-Ajax, Content-Type');
|
||||
res.setHeader('Access-Control-Allow-Origin', req.headers['origin'] || '*');
|
||||
if (req.headers['access-control-request-private-network'] === 'true') {
|
||||
res.setHeader('Access-Control-Allow-Private-Network', 'true');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = async (server) => {
|
||||
|
||||
const { api, env, path, util } = server;
|
||||
const { api, env, handler, path, util } = server;
|
||||
|
||||
server.inject("kiri", "main.js");
|
||||
|
||||
|
|
@ -17,6 +17,7 @@ module.exports = async (server) => {
|
|||
};
|
||||
|
||||
function proxy_post(req, res, next) {
|
||||
handler.addCORS(req, res);
|
||||
if (req.method === 'POST') {
|
||||
let { url, headers } = req;
|
||||
let chunks = [];
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
|
||||
if (proxy) {
|
||||
console.log('proxying request to', host);
|
||||
host = '';
|
||||
host = 'http://127.0.0.1:5309';
|
||||
}
|
||||
|
||||
filename = $('print-filename').value + "." + fileext;
|
||||
|
|
|
|||
Loading…
Reference in a new issue