我应该在什么文件中添加此代码以在节点js服务器中启用CORS?

时间:2017-06-10 01:08:02

标签: javascript node.js cors

  Create ROLE academic;       // I created the role 
  GRANT SELECT, INSERT, DELETE on student to academic; // Granted privileges
  GRANT academic to username; // passed it to user 

我正在尝试在我的节点js服务器中启用CORS。但是我不知道我应该在哪个文件中添加上面的代码。提前谢谢!

1 个答案:

答案 0 :(得分:0)

试试这个:

app.corsOrigin("http://localhost:8000"); // to particular url

app.corsOrigin("*");    //allow cors origin for all request url

或者您可以尝试this