跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 跨域:真的都是草台班子

发表于
今天关于跨域的这个帖子讨论很火 (捂脸笑) https://v2ex.com/t/1056504?p=1#reply197

我也想就看到的问题打点字。

首先,我不是前端。对于 why cors 的问题了解不是很多。大概知道的:
因为安全问题有了同源策略,因为现实不得不面对跨源问题,所以有了 cors 。至于更多的关于 why 的细节,我觉得安全人员和前端应该懂得更多(涉及具体规范之类),后端无需懂太多。但是后端需要懂关于 what 和 how 的问题。

++++++++++++++++++


谁来解决跨域问题?

这个问题,取决于你的系统架构。但一定是在 "浏览器环境的 web 前端"(简称前端) 之后的服务,需要确保给 "前端" 返回正确的 cors 要求的 header


如果你的系统链路是:前端---->web server 。 那自然是 web server 去解决 cors 问题

如果你的系统利阿努是: 前端---->nginx---->web server ,既可以是 nginx 也可以是 web server ,具体是
谁,看具体架构。(至于 nginx 是运维人员的活还是前后端人员的活,不讨论,每个项目人员配置不一哈,甚至可能就一个人)

至于前端开发时自己架个 node.js server 代理,如果从你的系统架构、人员配置各方面来讲,生产环境用这套架构也足够了,前端把这个活干了也没啥问题。


+++++++++++++

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.