Angular 5 / Node Express每个请求都使用新会话

时间:2017-12-08 17:38:34

标签: node.js angular express session express-session

我正在Angular 5中开发一个应用程序,它连接到我在NodeJS中的服务器。

我在用户登录后在req.session对象中添加用户。

当我从Angular 5应用程序发出第二个请求以从API检索内容时,req.session不包含用户,req.sessionId总是不同。

如何使会话持久?

以下是会话和cookieParser中间件:

CREATE TRIGGER like_notification AFTER INSERT ON user_likes_article
        FOR EACH ROW
        INSERT INTO notification (type, type_id, article_id, is_read, type_user_iduser_id)
        VALUES ('like', NEW.article_id, NEW.article_id, false, NEW.user_id,
            (
            SELECT user_id from channel WHERE channel_id IN
                (SELECT channel_id FROM article WHERE article_id = NEW.article_id)
            )
        WHERE NOT user_id = NEW.user_id;

>>>You have an error in your SQL syntax; check the manual that corresponds to your 
MariaDB server version for the right syntax to use near 'WHERE NOT user

1 个答案:

答案 0 :(得分:0)

这是与CORS相关的问题。我需要在Angular的http请求选项中包含{ withCredentials: true }

相关问题