dousonghs58612 2015-10-23 19:34
浏览 42

API设计-一个域上的应用程序,另一域上的api。 如何在不传递用户ID的情况下检索用户特定的数据

I am trying to build quite a simple web app (for learning purposes) using Golang and Angular JS.

I am comfortable with the Go and AngularJS code but I am having difficulties trying to create an adequate API structure.

At the moment I have all my code running the app and the API code bundled together.

Ideally I would like to separate this out, so I can have my app run on a subdomain such as app.mything.com and the API run on api.mything.com

The problem I have is my API has MYSQL calls such as -

select * FROM sometable where userid = userID

userID is a user ID that it is saved in a session.

So while all the code is bundled together this is possible and works fine. If I was to separate the code to two separate sub domains the session will not be accessible on both.

How is it possible to achieve something like this?

Thanks Dave

  • 写回答

2条回答 默认 最新

  • dongshie8450 2015-10-23 20:09
    关注

    There are two ways you can solve this:

    • Change the session storage to something the API and app both share (i.e.: MySQL).
    • Start using (encrypted) cookies instead of session data.
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭