500 internal server error on request to Node server from React client
Solution 1:
The response
returned by axios.get
has no set
method, because it is not an express response object. Therefore, your response.set("Access-Control-Allow-Origin", "*")
statement throws an exception, which you catch and convert into a 500 Internal Server Error.
What you probably want instead is
res.set("Access-Control-Allow-Origin", "*");
but that could be better achieved with an additional middleware
router.use(cors());
before the router.get("/models/:makeid", ...)
. (See the cors
package.)