إليك وضعي. أحاول تشغيل تثبيت لـ Discourse على talk.example.com مع الحفاظ على موقع ويب على www.example.com. أريد أن يكون الأمر بحيث عندما يسجل المستخدم دخوله إلى موقع Discourse، يظهر مسجّل الدخول أيضًا في موقع www. وإذا سجل الخروج من موقع Discourse، يتم تسجيل خروجه من www. لقد قرأت الكثير من المواضيع هنا، ويبدو أن الإجابة الشائعة هي استخدام SSO. لا أعتقد أن هذا يمكن أن يعمل في وضعي، وإليك السبب.
الموقع على www.example.com هو موقع ثابت مبني باستخدام Hugo. لأولئك الذين لا يعرفونه، فكّر في Jekyll. لذا لا يوجد قاعدة بيانات أو أي خلفية (backend) على الإطلاق. إنه ليس “تطبيقًا”. أنا أريد ببساطة أن يكون Discourse بمثابة خلفية وهمية لهذا الموقع الثابت. إذا كان لديهم إشعارات غير مقروءة على Discourse، أريد أن أتمكن من عرض ذلك لهم عبر الموقع الثابت.
الطريقة الوحيدة التي يمكنني التفكير فيها للقيام بذلك هي عبر ملفات تعريف الارتباط (cookies) الخاصة بـ Discourse التي لا تتضمن النطاق الفرعي، وهو ما تشير أبحاثي حتى الآن إلى أن Discourse لا يدعمه.
If the site was dynamic with a backend, and you had SSO between Discourse and site this would have a clear path forward. Your backend know who the user is, and can use an Admin API Key to query Discourse notifications for the current user and send it forward with the page on every request.
Since site is a static page, it doesn’t really have a logged-in state right?
Exactly. It’s just HTML, CSS, and typical front-end JavaScript.
In an ideal scenario I’d like to be able to use JavaScript on the static site, that runs in the browser, to be able to pull data from Discourse.
Notifications is one example and an embed for that would be great.
Another example, I’d love to be able to set a User Field over on Discourse for people to fill out. Then over on the static site, be able to access that user field to change how content is rendered (via JavaScript). For example, to re-order content to customize it for the user.
I know it’ll be an unsupported hack, but is there a way I can change how Discourse sets its session cookie to not include the subdomain, that will survive updates?