Sky020
(Shaun Hamilton)
2021 年9 月 8 日 16:04
1
大家好,
我们计划将 Discourse 徽章与我们的平台集成。也就是说,允许用户将其 Discourse 账户与我们平台上的账户进行关联。
为了链接账户,我们原本打算使用 Discourse Connect 。然而,在重定向过程中我们遇到了 CORS 错误:
Access to fetch at 'https://forum.freecodecamp.org/session/sso_provider?sso=<hash>'
(redirected from 'http://localhost:3000/discourse/connect') from origin
'http://localhost:8000' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
If an opaque response serves your needs, set the request's mode to 'no-cors'
to fetch the resource with CORS disabled.
我尝试了多种 Discourse Connect 的设置,包括将服务器、客户端和 Discourse 地址添加到 discourse connect provider secrets 中,但均无济于事。
澄清一下 :我们并不打算使用 Discourse Connect 来登录任何内容。
相关位置
freecodecamp.org - 平台域名
forum.freecodecamp.org - Discourse 实例子域名
localhost:3000 和 localhost:8000 - freecodecamp.org 开发环境的服务器和客户端
相关代码:
main ← ShaunSHamilton:feat/badges
closed 11:27AM - 08 Feb 22 UTC
Checklist:
- [x] I have read [freeCodeCamp's contribution guidelines](htt… ps://contribute.freecodecamp.org).
- [x] My pull request has a descriptive title (not a vague title like `Update index.md`)
- [x] My pull request targets the `main` branch of freeCodeCamp.
- [x] I have tested these changes either locally on my machine, or GitPod.
Closes #42837
**TODO**
- [ ] Look at potentially creating an epic for data handling
- [x] Integrate method to link Discourse and `/learn` accounts
- [ ] Clean up styling to be responsive
- [x] Change badge background to be same as container
- [x] Get new badge description and long description
- [ ] Link display of badges to existing privacy setting (My Portfolio?)
- [ ] Finalise how to display/order badges
- - [ ] Collapsable?
- - [ ] Show favourites above other Profile content?
- - [ ] Add more `badge_groups` to meta on Discourse?
As of _08/09/2021_
- My forum account is the only one with a new Badge awarded - for testing
- Discourse Connect does not have correct Headers to allow `localhost:8000` to be redirected
CC:/ @RafaelDavisH
return res.redirect(
`${FORUM_LOCATION}/session/sso_provider?sso=${URL_ENCODED_PAYLOAD}&sig=${HEX_SIGNATURE}`
);
任何帮助都将不胜感激。
我认为这种重定向流程是用于内容框架的,而不是 fetch 调用。例如,任何需要重定向到登录页面且无法重定向回来的情况都将无法工作,此外,跨域 Cookie 在这种情况下也会成为问题。
不如试试传统的弹窗窗口?