Skip to content

Commit bbe443f

Browse files
committed
Fixing env variable NAMESPACE on server and change axios base url on client
1 parent 32481d5 commit bbe443f

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

actions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const CancelToken = axios.CancelToken;
44
const source = CancelToken.source();
55

66
const axiosInstance = axios.create({
7-
baseURL: 'http://localhost:3000/api/v1',
7+
baseURL: `${process.env.BASE_URL}/api/v1`,
88
cancelToken: source.token
99
})
1010

pages/callback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function CallBack(props) {
1111
})
1212

1313
return (
14-
<BaseLayout>
14+
<BaseLayout title="Redirecting...">
1515
<BasePage>
1616
<p>VERIFYING DATA ...</p>
1717
</BasePage>

pages/portfolioNew.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ function portfolioNew(props) {
4444
})
4545
.catch(err => {
4646
setSubmitting(false);
47-
setError(err.message);
47+
setError(err);
4848
Swal.fire(
4949
'Failed',
50-
err.message,
50+
err,
5151
'error'
5252
);
5353
});

server/config/prod.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
// }
44

55
module.exports = {
6-
DB_URI : process.env.DB_URI
6+
DB_URI : process.env.DB_URI,
7+
NAMESPACE: 'https://anavas.herokuapp.com'
78
}

server/middlewares/auth.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ const jwt = require('express-jwt');
22
const { expressJwtSecret } = require('jwks-rsa');
33
const jwtAuthz = require('express-jwt-authz');
44

5-
const namespace = process.env.NAMESPACE;
5+
const config = require('../config');
6+
7+
const namespace = config.NAMESPACE;
68

79
//Web token validado
810
exports.jwtCheck = jwt({
@@ -23,7 +25,7 @@ exports.checkScopes = jwtAuthz(['read:portfolios'])
2325
//Check Role
2426
exports.checkRole = role => (req, res, next) => {
2527
const user = req.user
26-
if(user && (user[`${namespace}/role`] === role)) {
28+
if(user && user[`${namespace}/role`] && (user[`${namespace}/role`] === role)) {
2729
next();
2830
}else {
2931
return res.status(401).send({title: 'Not Authorized', detail: 'You are not authorized to access to this data'})

0 commit comments

Comments
 (0)