Skip to content

Commit

Permalink
fix(#9315): api v3 post, put, del JSON
Browse files Browse the repository at this point in the history
also allow `app.alertError` to be called without an argument
also fix `./nodebb build --dev` to actually build in dev mode
  • Loading branch information
pitaj authored and julianlam committed Feb 23, 2021
1 parent c5231f1 commit 0d59fe3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion public/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ app.cacheBuster = null;
};

app.alertError = function (message, timeout) {
message = message.message || message;
message = (message && message.message) || message;

if (message === '[[error:invalid-session]]') {
app.handleInvalidSession();
Expand Down
9 changes: 6 additions & 3 deletions public/src/modules/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ define('api', () => {
api.post = (route, payload, onSuccess) => call({
url: route,
method: 'post',
data: payload,
data: JSON.stringify(payload),
contentType: 'application/json; charset=utf-8',
headers: {
'x-csrf-token': config.csrf_token,
},
Expand All @@ -64,7 +65,8 @@ define('api', () => {
api.put = (route, payload, onSuccess) => call({
url: route,
method: 'put',
data: payload,
data: JSON.stringify(payload),
contentType: 'application/json; charset=utf-8',
headers: {
'x-csrf-token': config.csrf_token,
},
Expand All @@ -73,7 +75,8 @@ define('api', () => {
api.del = (route, payload, onSuccess) => call({
url: route,
method: 'delete',
data: payload,
data: JSON.stringify(payload),
contentType: 'application/json; charset=utf-8',
headers: {
'x-csrf-token': config.csrf_token,
},
Expand Down
8 changes: 4 additions & 4 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ nconf.argv(opts).env({
separator: '__',
});

const env = program.dev ? 'development' : (process.env.NODE_ENV || 'production');
process.env.NODE_ENV = env;
global.env = env;

prestart.setupWinston();

// Alternate configuration file support
Expand Down Expand Up @@ -197,6 +193,10 @@ program
.description(`Compile static assets ${'(JS, CSS, templates, languages)'.red}`)
.option('-s, --series', 'Run builds in series without extra processes')
.action((targets, options) => {
if (program.dev) {
process.env.NODE_ENV = 'development';
global.env = 'development';
}
require('./manage').build(targets.length ? targets : true, options);
})
.on('--help', () => {
Expand Down

0 comments on commit 0d59fe3

Please sign in to comment.