I am facing an issue with my Vue and .net application. Whenever I run "NPM start serve," it successfully builds the app. The app is running locally at: http://localhost:8080/ However, when I attempt to log in, I encounter the following error:
Console error:
Failed to load resource: net::ERR_CONNECTION_REFUSED localhost:50463/user/authenticate:1
I thought changing the port to 8080 in the axios.service.js file would resolve the error, but now I am getting a CORS headers error. How is changing the port causing this issue, and how can I resolve it?
I apologize if my question is unclear; I am new to .net and Vue and suspect this may be a routing problem, but I am unsure as the code was written by other developers, and I am still learning.
axios.service.js
const API_URL = 'http://localhost:50463/';
axios.defaults.baseURL = API_URL;
axios.defaults.headers.post['Content-Type'] = 'application/json';
axios.interceptors.response.use(
(a) => a,
(error) => {
if (!error.response) return Promise.reject({response: {data: 'Network Error'}});
else if (error && error.response && error.response.status === 401) {
store.dispatch('authentication/logout');
router.push('/');
window.location.replace('/');
//
}
return Promise.reject(error);
}
);
export const SetBearerToken = function(token) {
axios.defaults.headers.common['Authorization'] = token ? `Bearer ${token}` : null;
};
export const FilesUrl = API_URL + 'file/';
I have tried modifying the port in the API URL.
I have attempted to add the user I am logging in with to the database, but it requires some fields. I then used the details of a user already present in the database, but I am still encountering the same error.