javascript - How to solve cross-domain problems for the middle layer in node
大家讲道理2017-06-28 09:23:00
0
2
732
I have tried to use nginx, but I don’t know nginx at all. After configuring it for a long time, I still can’t figure it out. Is there any other simple method that can easily solve the cross-domain problem?
I don’t understand the role of your middle layer. Anyway, to solve the cross-domain problem, just add a field to the response header: Access-Control-Allow-Origin: * As for how to add it, you can useres.writeHeadYou can add it this way, or any other way. As long as you can see this header field in the final response returned to the browserok
I don’t understand the role of your middle layer. Anyway, to solve the cross-domain problem, just add a field to the response header:
Access-Control-Allow-Origin: *
As for how to add it, you can use
res.writeHead
You can add it this way, or any other way. As long as you can see this header field in the final response returned to the browserok
//Configure node cross-domain