Closed swamichandra closed 1 year ago
Hi @swamichandra , thanks for your question!
While the codebase is setup to run well locally, we've also made efforts to make cloud deployment easy for cloud providers we've chosen.
Render.com is another cloud platform similar to AWS, GCP, etc. but easier to use in many ways.
We actually have all of our backend infrastructure components defined through infrastructure-as-code in the render.yaml
blueprint file. Render has documentation here for connecting to the render.yaml
file within your repo for deploying to their platform. You would also need to setup the Environment Groups in Render according to the way they're defined in the render.yaml
template here. There are also some additional components to setup in terms of the two AWS S3 buckets and the Vercel deployment of the frontend. The YouTube tutorial video has a section on the system design that may be more informational.
If you'd like, we should be able to do a more in-depth write-up of how to go about cloud deployment. Let us know if that would be useful for you!
@sourabhdesai Thanks for the response and pointing me towards Render. I created all the env groups. llama-app-db and llama-app-cron are up. But the llama-app-backend service would not deploy and come up. See the following error where it fails. What does the DB not up to date mean?
Sep 9 01:34:27 PM ERROR: Traceback (most recent call last):
Sep 9 01:34:27 PM File "/root/.cache/pypoetry/virtualenvs/llama-app-backend-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 677, in lifespan
Sep 9 01:34:27 PM async with self.lifespan_context(app) as maybe_state:
Sep 9 01:34:27 PM File "/usr/local/lib/python3.11/contextlib.py", line 204, in __aenter__
Sep 9 01:34:27 PM return await anext(self.gen)
Sep 9 01:34:27 PM ^^^^^^^^^^^^^^^^^^^^^
Sep 9 01:34:27 PM File "/app/app/main.py", line 74, in lifespan
Sep 9 01:34:27 PM raise Exception(
Sep 9 01:34:27 PM Exception: Database is not up to date. Please run `poetry run alembic upgrade head`
Sep 9 01:34:27 PM
Sep 9 01:34:27 PM ERROR: Application startup failed. Exiting.
Hi @swamichandra , great to see your trying to setup the deployment for this!
Some context: The backend codebase manages database migrations with Alembic. This helps keep the database tables up-to-date with the latest ORM table definitions in the backend codebase (as defined here).
When trying to run this on Render.com, their service automatically sets the RENDER
environment variable to true
for you (see render docs on default env vars). This gets checked in main.py
here and if its set to true (as in, it's actually running on Render.com and not locally), it will run the alembic migrations for you.
For some reason, it seems like the migrations are not being run on service startup for your deployment. I'd take a look at the following:
alembic/versions
here.RENDER
environment variable yourself in any of the environment groups or service-level environment variablesYou may also be able to get it started by locally running alembic upgrade head
against the Render provided database. Just make sure to copy the database URL from the DB's webpage on Render and set it as the DATABASE_URL
environment variable value locally before running it.
At least that way, you'd be able to locally see what the error is and perhaps iterate towards a solution/workaround faster.
Once the DB migrations have been applied to your DB on Render, your service should start just fine
Hi @swamichandra , great to see your trying to setup the deployment for this!
Some context: The backend codebase manages database migrations with Alembic. This helps keep the database tables up-to-date with the latest ORM table definitions in the backend codebase (as defined here).
When trying to run this on Render.com, their service automatically sets the
RENDER
environment variable totrue
for you (see render docs on default env vars). This gets checked inmain.py
here and if its set to true (as in, it's actually running on Render.com and not locally), it will run the alembic migrations for you.For some reason, it seems like the migrations are not being run on service startup for your deployment. I'd take a look at the following:
- See if there is any indications in the service logs that database migrations were run but then failed to be fully applied. The service won't start unless DB migrations are caught up! It pulls the list of DB migrations to apply by checking the migrations defined so far in
alembic/versions
here.- Make sure you haven't set the
RENDER
environment variable yourself in any of the environment groups or service-level environment variables
@sourabhdesai The RENDER environment variable was the issue. I had to remove it from the env groups. The container now comes up fine.
Now to the next challenge and issue. When I run the the download_sec_pdf.py it only downloads the data locally. While the documentation says the docs would be uploaded to the S3 bucket. I don’t see it uploading anything to in the S3 bucket nor see any in the script that uploads to the bucket. Then I tried to run seed_db.py. Errors out when trying to upload to S3.
Any other way to load the data into the bucket and the DB?
@swamichandra that's great! Glad you got that part working.
So for loading the data, you will be able to use the cron job service that has also been deployed on Render. The cron job is defined in the render.yaml
file here.
As you can see, all it does is it runs make seed_db_based_on_env
which is defined in the backend's Makefile here.
The seed script that runs is really all you need to load in the SEC filings data into the service. That will pull the PDFs from SEC's Edgar API, upload them into S3, upsert references to them into the DB, and embed them if they haven't already been embedded. Of course, you will first need to have manually created a public S3 asset bucket that your AWS credentials have read/write access to.
Once you've got the S3 bucket and the Cron job setup, you should be able to manually trigger a run of your Cron job and have it do all the data loading for you. You can monitor the run on the Render dashboard.
@sourabhdesai thanks for being super responsive. I ran the cron and now see the files in the S3 bucket. But the cron threw the following errors. The frontend does not show any options for the year or company name. Looks like the db is still not configured properly.
@swamichandra great to see the progress you've made!
Right, so you may want to update the CDN_BASE_URL
values in the render.yaml
here to the public URL for your bucket.
Alternatively, you may also hook up Cloudfront to your S3 bucket and use the URL for the Cloudfront distribution for CDN_BASE_URL
instead.
@sourabhdesai Thanks again. Very close. It was the S3 bucket policy I had to update to allow public access. Now the cron works and I’m seeing it successfully.
I have the front end also provisioned on Vercel and it comes up. I doubled checked and the NEXT_PUBLIC_BACKEND_URL points to the backend url on Render. But I don’t see the company names getting pulled up in the UI when I type. Wondering if I’m missing a step.
Hmm can you check if the /api/document/
endpoint on your render deployed backend is showing any documents? If not there may have been an issue loading the documents into the documents
table of your database 🤔 might be worth trying to run the seed script locally against your render DB and using pdb
to step through the part of the script where it loads rows into the DB.
I see this (small snippet).
[{"id":"3aae3da2-6969-4fa2-adfb-cf0173afc62e","created_at":"2023-09-10T03:57:06.398480","updated_at":"2023-09-10T03:57:06.398480","url":"https://d687lz8k56fia.cloudfront.net/sec-edgar-filings/0000078003/10-Q/0000078003-23-000088/filing-details.pdf","metadata_map":{"sec_document":{"cik":"0000078003","year":2023,"quarter":2,"doc_type":"10-Q","company_name":"Pfizer Inc.","company_ticker":"PFE","accession_number":"0000078003-23-000088","filed_as_of_date":"2023-08-09T00:00:00","date_as_of_change":"2023-08-09T00:00:00","period_of_report_date":"2023-07-02T00:00:00"}}},{"id":"38b8f00b-5ea3-4514-8a5f-26a10d50bf7f","created_at":"2023-09-10T03:57:06.384585","updated_at":"2023-09-10T03:57:06.384585","url":"https://d687lz8k56fia.cloudfront.net/sec-edgar-filings/0000078003/10-K/0000078003-21-000038/filing-details.pdf","metadata_map":{"sec_document":{"cik":"0000078003","year":2020,"doc_type":"10-K","company_name":"Pfizer Inc.","company_ticker":"PFE","accession_number":"0000078003-21-000038","filed_as_of_date":"2021-02-25T00:00:00","date_as_of_change":"2021-02-25T00:00:00","period_of_report_date":"2020-12-31T00:00:00"}}},{"id":"df97d890-85d6-4179-846c-4bcff8e8c35e","created_at":"2023-09-10T03:57:06.412024","updated_at":"2023-09-10T03:57:06.412024","url":"https://d687lz8k56fia.cloudfront.net/sec-edgar-filings/0001633917/10-K/0001633917-21-000018/filing-details.pdf","metadata_map":{"sec_document":{"cik":"00016
Hmmm so it seems your DB has the documents loaded in.
It may just be that you need to add your Vercel frontend URL to the CORS access list in this part of the render.yaml
. Once you've added your Vercel URL to that list your frontend should be able to make the requests. Hopefully that does the trick!
Thanks for going through this process! This definitely has given me some insight on what I should include if I were to write up a deployment guide for the project 🙂
Also FYI, looking at your snippet, it seems like document URLs loaded into your DB are still referencing our project's Cloudfront CDN url. So the PDFs are actually being loaded from our CDN distribution instead of your S3 bucket 😅 may want to update the CDN_BASE_URL
in your render.yaml
and re-run the cron job to avoid confusion as to where your PDF docs are being loaded from. You may need to truncate your documents table in the DB before doing this to avoid duplication of these documents in that table.
Is there a way or a script I can run to reinitialize the DB from scratch? Drop the db incl all the tables and recreate them? I cannot truncate the Documents table. Get a referential integrity error.
@sourabhdesai Should the CORS value be singular? If I provide a list like what you have I get a deployment failure with a“error parsing env bar BACKEND_CORS_ORIGINS”
When I provide the value below for CORS it fails. Build works only for a single value: '["http://localhost", "http://localhost:8000", "http://localhost:3000", "http://127.0.0.1:3000", "https://xxx.onrender.com", "https://swami-companygpt.vercel.app/", "http://secinsights.ai", "http://www.secinsights.ai", "https://secinsights.ai", "https://www.secinsights.ai"]'
Still I have no luck in having the vercel frontend pull up the data from the database. I still see this CORS issue in my browser,
Access to fetch at 'https://xxx.onrender.com/api/document/' from origin 'https://xxx.vercel.app' has been blocked by CORS policy: 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.
Is there a way or a script I can run to reinitialize the DB from scratch? Drop the db incl all the tables and recreate them? I cannot truncate the Documents table. Get a referential integrity error.
Yes! You should be able to run alembic downgrade base
against your DB to downgrade the DB migrations back to the starting point when there were no tables (see alembic docs on this here).
Should the CORS value be singular?
Hmm it should be able to take in a List 🤔 totally speculating but try removing the trailing /
from "https://swami-companygpt.vercel.app/"
?
I've also seen that sometimes the browser caching can get in the way of CORS policy updates. After updating your CORS allow list, may be worth clearing your site-level browser cache as a sanity check.
Should the CORS value be singular?
Hmm it should be able to take in a List 🤔 totally speculating but try removing the trailing
/
from"https://swami-companygpt.vercel.app/"
?I've also seen that sometimes the browser caching can get in the way of CORS policy updates. After updating your CORS allow list, may be worth clearing your site-level browser cache as a sanity check.
@sourabhdesai Removed the trailing slash. Still getting the error parsing env var "BACKEND_CORS_ORIGINS" error.
BACKEND_CORS_ORIGINS : '["https://llama-app-backend-7jtv.onrender.com", "https://swami-companygpt.vercel.app", "https://llama-app-backend-7jtv.onrender.com/api/document"]'
Sep 11 06:43:39 PM Traceback (most recent call last):
Sep 11 06:43:39 PM File "pydantic/env_settings.py", line 198, in pydantic.env_settings.EnvSettingsSource.__call__
Sep 11 06:43:39 PM File "pydantic/env_settings.py", line 132, in pydantic.env_settings.Config.parse_env_var
Sep 11 06:43:39 PM File "/usr/local/lib/python3.11/json/__init__.py", line 346, in loads
Sep 11 06:43:39 PM return _default_decoder.decode(s)
Sep 11 06:43:39 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:39 PM File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
Sep 11 06:43:39 PM obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Sep 11 06:43:39 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:39 PM File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
Sep 11 06:43:39 PM raise JSONDecodeError("Expecting value", s, err.value) from None
Sep 11 06:43:39 PM json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Sep 11 06:43:39 PM
Sep 11 06:43:39 PM The above exception was the direct cause of the following exception:
Sep 11 06:43:39 PM
Sep 11 06:43:39 PM Traceback (most recent call last):
Sep 11 06:43:39 PM File "<string>", line 1, in <module>
Sep 11 06:43:39 PM File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
Sep 11 06:43:39 PM return _bootstrap._gcd_import(name[level:], package, level)
Sep 11 06:43:39 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:39 PM File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
Sep 11 06:43:39 PM File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
Sep 11 06:43:39 PM File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
Sep 11 06:43:39 PM File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
Sep 11 06:43:39 PM File "<frozen importlib._bootstrap_external>", line 940, in exec_module
Sep 11 06:43:39 PM File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
Sep 11 06:43:39 PM File "/app/app/main.py", line 15, in <module>
Sep 11 06:43:39 PM from app.api.api import api_router
Sep 11 06:43:39 PM File "/app/app/api/api.py", line 3, in <module>
Sep 11 06:43:39 PM from app.api.endpoints import conversation, health, documents
Sep 11 06:43:39 PM File "/app/app/api/endpoints/conversation.py", line 10, in <module>
Sep 11 06:43:39 PM from app.api.deps import get_db
Sep 11 06:43:39 PM File "/app/app/api/deps.py", line 3, in <module>
Sep 11 06:43:39 PM from app.db.session import SessionLocal
Sep 11 06:43:39 PM File "/app/app/db/session.py", line 4, in <module>
Sep 11 06:43:39 PM from app.core.config import settings
Sep 11 06:43:39 PM File "/app/app/core/config.py", line 169, in <module>
Sep 11 06:43:39 PM settings = Settings()
Sep 11 06:43:39 PM ^^^^^^^^^^
Sep 11 06:43:39 PM File "pydantic/env_settings.py", line 41, in pydantic.env_settings.BaseSettings.__init__
Sep 11 06:43:39 PM File "pydantic/env_settings.py", line 76, in pydantic.env_settings.BaseSettings._build_values
Sep 11 06:43:39 PM File "pydantic/env_settings.py", line 201, in pydantic.env_settings.EnvSettingsSource.__call__
Sep 11 06:43:39 PM pydantic.env_settings.SettingsError: error parsing env var "BACKEND_CORS_ORIGINS"
Sep 11 06:43:47 PM Traceback (most recent call last):
Sep 11 06:43:47 PM File "pydantic/env_settings.py", line 198, in pydantic.env_settings.EnvSettingsSource.__call__
Sep 11 06:43:47 PM File "pydantic/env_settings.py", line 132, in pydantic.env_settings.Config.parse_env_var
Sep 11 06:43:47 PM File "/usr/local/lib/python3.11/json/__init__.py", line 346, in loads
Sep 11 06:43:47 PM return _default_decoder.decode(s)
Sep 11 06:43:47 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:47 PM File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
Sep 11 06:43:47 PM obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Sep 11 06:43:47 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:47 PM File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
Sep 11 06:43:47 PM raise JSONDecodeError("Expecting value", s, err.value) from None
Sep 11 06:43:47 PM json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Sep 11 06:43:47 PM
Sep 11 06:43:47 PM The above exception was the direct cause of the following exception:
Sep 11 06:43:47 PM
Sep 11 06:43:47 PM Traceback (most recent call last):
Sep 11 06:43:47 PM File "<string>", line 1, in <module>
Sep 11 06:43:47 PM File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
Sep 11 06:43:47 PM return _bootstrap._gcd_import(name[level:], package, level)
Sep 11 06:43:47 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:47 PM File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
Sep 11 06:43:47 PM File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
Sep 11 06:43:47 PM File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
Sep 11 06:43:47 PM File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
Sep 11 06:43:47 PM File "<frozen importlib._bootstrap_external>", line 940, in exec_module
Sep 11 06:43:47 PM File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
Sep 11 06:43:47 PM File "/app/app/main.py", line 15, in <module>
Sep 11 06:43:47 PM from app.api.api import api_router
Sep 11 06:43:47 PM File "/app/app/api/api.py", line 3, in <module>
Sep 11 06:43:47 PM from app.api.endpoints import conversation, health, documents
Sep 11 06:43:47 PM File "/app/app/api/endpoints/conversation.py", line 10, in <module>
Sep 11 06:43:47 PM from app.api.deps import get_db
Sep 11 06:43:47 PM File "/app/app/api/deps.py", line 3, in <module>
Sep 11 06:43:47 PM from app.db.session import SessionLocal
Sep 11 06:43:47 PM File "/app/app/db/session.py", line 4, in <module>
Sep 11 06:43:47 PM from app.core.config import settings
Sep 11 06:43:47 PM File "/app/app/core/config.py", line 169, in <module>
Sep 11 06:43:47 PM settings = Settings()
Sep 11 06:43:47 PM ^^^^^^^^^^
Sep 11 06:43:47 PM File "pydantic/env_settings.py", line 41, in pydantic.env_settings.BaseSettings.__init__
Sep 11 06:43:47 PM File "pydantic/env_settings.py", line 76, in pydantic.env_settings.BaseSettings._build_values
Sep 11 06:43:47 PM File "pydantic/env_settings.py", line 201, in pydantic.env_settings.EnvSettingsSource.__call__
Sep 11 06:43:47 PM pydantic.env_settings.SettingsError: error parsing env var "BACKEND_CORS_ORIGINS"
Sep 11 06:43:54 PM Traceback (most recent call last):
Sep 11 06:43:54 PM File "pydantic/env_settings.py", line 198, in pydantic.env_settings.EnvSettingsSource.__call__
Sep 11 06:43:54 PM File "pydantic/env_settings.py", line 132, in pydantic.env_settings.Config.parse_env_var
Sep 11 06:43:54 PM File "/usr/local/lib/python3.11/json/__init__.py", line 346, in loads
Sep 11 06:43:54 PM return _default_decoder.decode(s)
Sep 11 06:43:54 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:54 PM File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
Sep 11 06:43:54 PM obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Sep 11 06:43:54 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:54 PM File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
Sep 11 06:43:54 PM raise JSONDecodeError("Expecting value", s, err.value) from None
Sep 11 06:43:54 PM json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Sep 11 06:43:54 PM
Sep 11 06:43:54 PM The above exception was the direct cause of the following exception:
Sep 11 06:43:54 PM
Sep 11 06:43:54 PM Traceback (most recent call last):
Sep 11 06:43:54 PM File "<string>", line 1, in <module>
Sep 11 06:43:54 PM File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
Sep 11 06:43:54 PM return _bootstrap._gcd_import(name[level:], package, level)
Sep 11 06:43:54 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 06:43:54 PM File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
Sep 11 06:43:54 PM File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
Sep 11 06:43:54 PM File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
Sep 11 06:43:54 PM File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
Sep 11 06:43:54 PM File "<frozen importlib._bootstrap_external>", line 940, in exec_module
Sep 11 06:43:54 PM File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
Sep 11 06:43:54 PM File "/app/app/main.py", line 15, in <module>
Sep 11 06:43:54 PM from app.api.api import api_router
Sep 11 06:43:54 PM File "/app/app/api/api.py", line 3, in <module>
Sep 11 06:43:54 PM from app.api.endpoints import conversation, health, documents
Sep 11 06:43:54 PM File "/app/app/api/endpoints/conversation.py", line 10, in <module>
Sep 11 06:43:54 PM from app.api.deps import get_db
Sep 11 06:43:54 PM File "/app/app/api/deps.py", line 3, in <module>
Sep 11 06:43:54 PM from app.db.session import SessionLocal
Sep 11 06:43:54 PM File "/app/app/db/session.py", line 4, in <module>
Sep 11 06:43:54 PM from app.core.config import settings
Sep 11 06:43:54 PM File "/app/app/core/config.py", line 169, in <module>
Sep 11 06:43:54 PM settings = Settings()
Sep 11 06:43:54 PM ^^^^^^^^^^
Sep 11 06:43:54 PM File "pydantic/env_settings.py", line 41, in pydantic.env_settings.BaseSettings.__init__
Sep 11 06:43:54 PM File "pydantic/env_settings.py", line 76, in pydantic.env_settings.BaseSettings._build_values
Sep 11 06:43:54 PM File "pydantic/env_settings.py", line 201, in pydantic.env_settings.EnvSettingsSource.__call__
Sep 11 06:43:54 PM pydantic.env_settings.SettingsError: error parsing env var "BACKEND_CORS_ORIGINS"
@swamichandra Hm I wasn't able to replicate this on my end. I have set that line in my .env
to BACKEND_CORS_ORIGINS='["https://llama-app-backend-7jtv.onrender.com", "https://swami-companygpt.vercel.app", "https://llama-app-backend-7jtv.onrender.com/api/document"]'
and its not giving me any error when trying to parse the en variable. Were you able to figure this last part out?
@sourabhdesai I’m going to redo all on Render and reprovision. I’m not able to point out why the list of CORS value throws an error.
@sourabhdesai Good news. I deleted all the services in Render and recreated them. Including the AWS S3 buckets. Reran the cron to repopulate the documents. Backend comes up fine.
One major thing I did was to remove the single quotes (‘) at the start and end of the BACKEND_CORS_ORIGINS list. Now the backend starts without any errors.
The error I’m facing now is I get a “ Failed to load PDF file” error message. I see in the browser dev tools the 037f8f29-cfe2-4cbb-bec9-abc2c037ca45:1 Access to fetch at 'xxx/sec-edgar-filings/0001018724/10-K/0001018724-23-000004/filing-details.pdf' from origin 'xxx' has been blocked by CORS policy: 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.
I added to BACKEND_CORS_ORIGINS the S3 URL. What could I be missing?
@swamichandra you have to give bucket cors in localstack.
awslocal s3api put-bucket-cors --bucket ${S3_ASSET_BUCKET_NAME} --cors-configuration file://./localstack-cors-config.json
for more you can check doc of localstack: https://docs.localstack.cloud/user-guide/aws/s3/#configuring-cross-origin-resource-sharing-on-s3
@swamichandra you have to give bucket cors in localstack.
awslocal s3api put-bucket-cors --bucket ${S3_ASSET_BUCKET_NAME} --cors-configuration file://./localstack-cors-config.json
for more you can check doc of localstack: https://docs.localstack.cloud/user-guide/aws/s3/#configuring-cross-origin-resource-sharing-on-s3
@jigneshsolanki I’m running the backend on Render and not localstack.
@sourabhdesai Good news. I deleted all the services in Render and recreated them. Including the AWS S3 buckets. Reran the cron to repopulate the documents. Backend comes up fine.
One major thing I did was to remove the single quotes (‘) at the start and end of the BACKEND_CORS_ORIGINS list. Now the backend starts without any errors.
The error I’m facing now is I get a “ Failed to load PDF file” error message. I see in the browser dev tools the 037f8f29-cfe2-4cbb-bec9-abc2c037ca45:1 Access to fetch at 'xxx/sec-edgar-filings/0001018724/10-K/0001018724-23-000004/filing-details.pdf' from origin 'xxx' has been blocked by CORS policy: 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.
I added to BACKEND_CORS_ORIGINS the S3 URL. What could I be missing?
@swamichandra Most likely what you're seeing is that your frontend is trying to access the server that is hosting your PDF files (whether that's the S3 bucket configured in website mode or through a Cloufront CDN) but that service doesn't have CORS configured to allow access to your frontend.
Depending on how you're serving your PDFs to the frontend, either of the above articles may be helpful.
Very informative thread. I'm sure I'm not alone in saying I would love for a full deployment tutorial! Great repo!
Closing as there seems to not be any further questions
Not a defect, but an ask. The backend components are tightly coupled together and assume everything runs locally. Any attempt to allow for deploying the backend to AWS or GCP or Azure and allowing for respective cloud native services to be used?