Permalink
Browse files

Add configuration for ROOT_URL accessible via JS

  • Loading branch information...
rubyhero committed Jul 8, 2018
1 parent 5a1e9df commit cd0288276e551250310af3dc7db2a72f76cda1eb
@@ -43,7 +43,7 @@ class NewCommentForm extends React.Component {
$("div[class='invalid-feedback']").text('');
postRequest(
"http://localhost:3000/p/" + this.props.post_id + "/comments",
"p/" + this.props.post_id + "/comments",
this.props.csrf_token, body, this.handleResponse, this
);
}
@@ -46,7 +46,7 @@ class NewPostForm extends React.Component {
$("div[class='invalid-feedback']").hide();
$("div[class='invalid-feedback']").text('');
postRequest(
"http://localhost:3000/p",
"p",
this.props.csrf_token, body, this.handleResponse, this
);
}
@@ -1,5 +1,5 @@
export const postRequest = (url, csrf_token, params, callback, context) => {
fetch(url, {
export const postRequest = (path, csrf_token, params, callback, context) => {
fetch(process.env.ROOT_URL + path, {
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest',
@@ -1,5 +1,12 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
const environment = require('./environment')
const webpack = require('webpack')
environment.plugins.append(
'EnvironmentPlugin',
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
ROOT_URL: 'http://localhost:3000/'
})
)
module.exports = environment.toWebpackConfig()

0 comments on commit cd02882

Please sign in to comment.