I'm having an issue previewing my app since switching to loading the data from the VueX store (db.json) file as opposed to the online version of the json file.
On Chrome I'm getting the error:
GET http://localhost:3000/events net::ERR_CONNECTION_REFUSED
On Firefox I'm getting the error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3000/events. (Reason: CORS request did not succeed)
I have tried a few different things such as adding in the Access-Control headers, setting the credentials to true, and trying this on the 127.0.0.1 address as opposed to localhost but still not having any luck.
My EventService.js file that performs the Axios call is:
import axios from 'axios'
const apiClient = axios.create({
baseURL: 'http://localhost:3000',
withCredentials: false,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, PUT, POST',
'Access-Control-Allow-Headers': 'Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With'
}
})
export default {
getEvents() {
return apiClient.get('/events')
},
getEvent(id) {
return apiClient.get('/events/' + id)
},
postEvent(event) {
return apiClient.post('/events', event)
}
}
It just keeps defaulting back to my NetworkError component fall back when the connection can't be established.