You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, after installing umami on my own server, I tried to get token in JavaScript code and failed. I did succeed in getting websites statistics in JavaScript code, using token from another way.
At first I thought this was a cross-origin resource problem, after I configured nginx with 'Access-Control-Allow-Origin *' , I was told there were ' *, * ', then I realized that maybe umami server already configured about cors.
But I'm still wondering if there any chance to get token through JavaScript code, and I do know that it's not wise to save password in code.
This is my way to send post request
`
const url = 'https://umami.my-domain.com';
const axios = require('axios');
const user_info = {
'username' : 'admin',
'password' : 'some-password'
};
const url_token = url + "/api/auth/login";
axios.post(url_token, user_info)
.then(response => {
console.log("ok1");
})
.catch(error => {
console.log("error1");
});
`
Please let me konw where goes wrong.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, after installing umami on my own server, I tried to get token in JavaScript code and failed. I did succeed in getting websites statistics in JavaScript code, using token from another way.
At first I thought this was a cross-origin resource problem, after I configured nginx with 'Access-Control-Allow-Origin *' , I was told there were ' *, * ', then I realized that maybe umami server already configured about cors.
But I'm still wondering if there any chance to get token through JavaScript code, and I do know that it's not wise to save password in code.
This is my way to send post request
`
const url = 'https://umami.my-domain.com';
const axios = require('axios');
const user_info = {
'username' : 'admin',
'password' : 'some-password'
};
const url_token = url + "/api/auth/login";
axios.post(url_token, user_info)
.then(response => {
console.log("ok1");
})
.catch(error => {
console.log("error1");
});
`
Please let me konw where goes wrong.
Beta Was this translation helpful? Give feedback.
All reactions