Hi,
I'm working on a web controller for Duet. The web control software is hosted on the internet, and accessed via a PC. The PC is connected to the printer with Duet 3 6HC with the SBC set as an access point.
When the printer and software start, it works like a charm. Connects, GET, and POST requests can be made. However, if reset is hit (on the DWC, M112 code or physically pushing the reset button), I receive the following error when trying to reconnect:
Access to XMLHttpRequest at 'http://192.168.1.10/machine/connect?password=reprap' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
It seems that no matter what we do on the server side, nothing works only after either, the printer has been turn off and on again, or the webserver has been restarted (sudo systemctl restart duetwebserver
via SSH).
This our httpRequest function, using AxiosRequest
export async function httpRequest(config: IRequestConfig) {
const fullUrl = `http://${PRINT_WEBSERVER}${config.url}`;
console.log(`Request to ${fullUrl}`);
const request: AxiosRequestConfig = {
...config,
url: fullUrl,
};
try {
const response = await axios(request);
}
console.log(`Success! - Request to ${fullUrl} returned`, response.data);
return response;
} catch (e: any) {
console.log(`Failed! - Request to ${fullUrl} returned ${e.status} - ${e.message}`);
throw e;
}
}
How to connect to the printer again, after a reset or how can we reset the webserver via JS?