feat: 后端支持嵌入第三方

This commit is contained in:
shaohuzhang1 2023-12-12 11:25:54 +08:00
parent 1e2ed4af88
commit 5488804ea8
4 changed files with 6 additions and 4 deletions

View File

@ -47,7 +47,7 @@ MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
JWT_AUTH = {

View File

@ -77,7 +77,9 @@ def page_not_found(request, exception):
file = open(index_path, "r", encoding='utf-8')
content = file.read()
file.close()
return HttpResponse(content, status=200)
if request.path.startswith('/ui/chat/'):
return HttpResponse(content, status=200)
return HttpResponse(content, status=200, headers={'X-Frame-Options': 'DENY'})
handler404 = page_not_found

View File

@ -200,7 +200,7 @@ const getChatOpen: (applicaiton_id: String) => Promise<Result<any>> = (applicait
}
*/
const postChatMessage: (chat_id: string, message: string) => Promise<any> = (chat_id, message) => {
return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message })
return postStream(`/api${prefix}/chat_message/${chat_id}`, { message })
}
/**

View File

@ -71,7 +71,7 @@ allow="microphone">
host: "${window.location.host}"
}
<\/script>
<script src="${window.location.origin}/ui/embed.js">
<script src="${window.location.origin}/ui/embeb.js">
<\/script>
`
dialogVisible.value = true