我正在使用express-cors npm 包,但任何方式都可以:
我在公共路线上尝试过这个:
// @ /routes/index.js
var cors = require('express-cors');
var express = require('express');
var router = express.Router();
// Set cross-origin rules
router.use(cors({
    allowedOrigins: [
        '*'
    ]
}));
// GET home page
router.get('/', function(req, res, next) {
    res.render('index', { title: 'tol-node-public' });
});
module.exports = router;
Run Code Online (Sandbox Code Playgroud)
我还尝试了私人路线以允许从我的网站访问:
// Set cross-origin rules
router.use(cors({
     allowedOrigins: [
         'https://*.mysite.*'
     ]
}));
Run Code Online (Sandbox Code Playgroud)
但是在我的 Ajax 调用中:
$.ajax({
    url: 'https://api.mysite.com/',
    dataType: 'html',
    type: 'GET',
    success: function (res) {
        console.log( "NODE SERVER STATUS: " + JSON.stringify(res) ); …Run Code Online (Sandbox Code Playgroud) 我在Unity 5.6上的Windows(VS2017社区)上有这个片段:
public static void setClipboardStr(string str)
{
    try
    {
        if (Clipboard.ContainsText())
        {
            // ...doesn't matter if true or false - 
            // from here on, I can't copy+paste inside 
            // the game or outside until I close the app. 
            // If I had an error instead of try/catch or 
            // check if it contains text, the error will 
            // remain UNTIL I REBOOT (beyond the app closing).
        }
    }
    catch(Exception ex)
    {
        Debug.LogError(ex);
    }
}
Run Code Online (Sandbox Code Playgroud)
每当我以任何形式使用剪贴板时,即使检查它是否是文本,它都会破坏剪贴板,直到我关闭应用程序.现在,这是一个Unity错误吗?VS bug?有什么我不理解的吗?我应该用什么呢?