Use HTTP body instead of header for setting flows run state

This commit is contained in:
Steve-Mcl 2022-06-27 18:03:14 +01:00
parent 6b6004ee70
commit 2f1f587c50
3 changed files with 4 additions and 7 deletions

View File

@ -83,7 +83,7 @@ module.exports = {
postState: function(req,res) {
const opts = {
user: req.user,
requestedState: req.get("Node-RED-Flow-Run-State-Change")||"",
requestedState: req.body.state||"",
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.setState(opts).then(function(result) {

View File

@ -306,10 +306,7 @@ RED.deploy = (function() {
$.ajax({
url:"flows/state",
type: "POST",
data: {state: state},
headers: {
"Node-RED-Flow-Run-State-Change": state
}
data: {state: state}
}).done(function(data,textStatus,xhr) {
if (deployWasEnabled) {
$("#red-ui-header-button-deploy").removeClass("disabled");

View File

@ -254,7 +254,7 @@ describe("api/admin/flows", function() {
request(app)
.post('/flows/state')
.set('Accept', 'application/json')
.set('Node-RED-Flow-Run-State-Change', 'stop')
.send({state:'stop'})
.expect(200)
.end(function (err, res) {
if (err) {
@ -295,7 +295,7 @@ describe("api/admin/flows", function() {
request(app)
.post('/flows/state')
.set('Accept', 'application/json')
.set('Node-RED-Flow-Run-State-Change', 'bad-state')
.send({state:'bad-state'})
.expect(400)
.end(function(err,res) {
if (err) {