Sky020
(Shaun Hamilton)
2021 年 9 月 8 日午後 4: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 呼び出しではなく、コンテンツフレーム向けに意図されたものだと考えられます。例えば、ログインページにリダイレクトして戻ってこないようなケースは機能せず、この方法ではクロスオリジンのクッキーにも問題が生じます。
昔ながらのポップアップウィンドウを使ってみてはいかがでしょうか?