I'm using this tutorial: https://blog.logrocket.com/mern-stack-tutorial/ , but building a bug tracker instead of a book repository.
When I load the root path in the client, I load a ReactJS component ('ShowBugList.js'). That file makes a request to the server (in the same goorm container).
In ShowBugList.js
componentDidMount() {
axios
.get('http://localhost:8082/api/bugs/')
.then((res) => {
this.setState({
bugs: res.data,
});
})
.catch((err) => {
console.log('Error from ShowBugList');
console.log(err);
});
}
And I'm getting an error there.
I'm also unable to reach that API with postman(of course replacing 'localhost' with the goorm container address).
I checked my web server port and it is 8082.
const port = process.env.PORT || 8082;
app.listen(port, () => console.log(`Server running on port ${port}`));
I'm also, using that route
const bugs = require('./routes/api/bugs');
app.use('/api/bugs/', bugs);
What am I overlooking here?
EDIT 1: I should add that I've looked into any CORS issues and I think I have the correct settings for it in my server-side app.js:
// cors
app.use(cors({ origin: true, credentials: true }));
EDIT 2: Set up a local version on my computer of this and reproduced the issue. So it's not a GoormIDE specific issue but something within the code itself. The search continues.
EDIT 3: I had input https as per the suggestion below and it was causing my error when I moved to a local installation. Going back to http on my local installation got that working. But I'll leave this question open if any one has ideas how to get it working on goorm.