This repository has been archived by the owner on Jan 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from openchatai/staging
Staging
- Loading branch information
Showing
10 changed files
with
170 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Use the official Nginx image | ||
FROM nginx | ||
|
||
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf.template | ||
COPY ./entrypoint-nginx.sh /entrypoint-nginx.sh | ||
RUN chmod +x /entrypoint-nginx.sh | ||
ENTRYPOINT ["/entrypoint-nginx.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.utils.deprecation import MiddlewareMixin | ||
from web.models.chatbot import Chatbot | ||
import os | ||
|
||
class CorsMiddleware(MiddlewareMixin): | ||
def process_response(self, request, response): | ||
# Get the origin of the request | ||
origin = request.META.get('HTTP_ORIGIN') | ||
|
||
# Check if the origin is in the database | ||
# Get APP_URL from environment variables | ||
app_url = os.getenv('APP_URL') | ||
#print(f"Origin of the APP_URL: {app_url} == {origin}") | ||
|
||
# Check if the origin is in the database or equal to APP_URL | ||
origin_in_db = origin == app_url or Chatbot.objects.filter(website=origin).exists() | ||
|
||
if origin_in_db: | ||
# Add the 'Access-Control-Allow-Origin' header to the response | ||
response['Access-Control-Allow-Origin'] = origin | ||
response['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS' | ||
response['Access-Control-Allow-Headers'] = 'X-Requested-With, Content-Type, X-Bot-Token' | ||
|
||
#print(f"Website URLs checked: {[chatbot.website for chatbot in Chatbot.objects.all()]}") | ||
# print(f"Response status code: {response.status_code}") | ||
# print(f"Response content: {response.content}") | ||
#print(f"Response headers: {response.headers}") | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Remove 'http://' or 'https://' prefix from APP_URL | ||
CLEANED_APP_URL=${APP_URL#http://} | ||
CLEANED_APP_URL=${APP_URL#https://} | ||
|
||
echo "Replacing APP_URL with $CLEANED_APP_URL" | ||
|
||
# Define the file path as a variable, for example: | ||
NGINX_CONF="/etc/nginx/nginx.conf" | ||
|
||
sed "s|yourdomain.com|$CLEANED_APP_URL|g" NGINX_CONF > /tmp/nginx.conf | ||
mv /tmp/nginx.conf NGINX_CONF | ||
|
||
# Start your app normally | ||
# exec nginx -g "daemon off;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
dj_backend_server/web/migrations/0006_crawledpages_content_file.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.3 on 2023-10-27 17:32 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('web', '0005_pdfdatasourceerrorlog'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='crawledpages', | ||
name='content_file', | ||
field=models.CharField(max_length=255, null=True), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
dj_backend_server/web/migrations/0007_alter_crawledpages_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.3 on 2023-10-27 17:49 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('web', '0006_crawledpages_content_file'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='crawledpages', | ||
name='id', | ||
field=models.AutoField(primary_key=True, serialize=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters