Closed caitreid closed 1 year ago
Updates:
DATABASES = {
'default': dj_database_url.config(
default='postgresql://postgres:postgres@localhost:5432/<name_of_database>',
conn_max_age=600 )
}
so that's working(!)
I think I need to update this file, apiConfig.js
in the frontend of react
let apiUrl
const apiUrls = {
// YOU MUST CHANGE PRODUCTION URL WHEN DEPLOYING
production: '<URL>',
development: 'http://localhost:8000/',
}
if (window.location.hostname === 'localhost') {
apiUrl = apiUrls.development
} else {
apiUrl = apiUrls.production
}
export default apiUrl`
I think I need to point it at bit.io's API.
I'm looking at the docs, https://docs.bit.io/docs/connecting-via-the-api I've played with curl requests to see if i can tap the api, but so far no luck
e.g.
API_KEY=<my_actual_key>
curl --request GET \
--url https://api.bit.io/v2beta/query/db/caitlinreid/mp_db \
--header "Authorization: Bearer ${API_KEY}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{"query_string":"SELECT * FROM api_mangos LIMIT 10;", "database_name":"mp_db"}'
still looking into whether I've structured this URL correctly - https://api.bit.io/v2beta/query/db/caitlinreid/mp_db
For your apiurls you should add in your render backend link as your production URL
thank you! ill try that
Ok - I've deployed backend to Render.
I've added the Render API url to apiConfig.js
I also added a key in Render CLIENT_ORIGIN
to my deployed React app
But now I'm getting a CORS error trying to log in from frontend
Access to XMLHttpRequest at 'https://mp-backend-6a39.onrender.com/sign-in/' from origin 'https://luxury-gingersnap-ca0ccf.netlify.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I needed to update my SECRET env from SECRET_KEY to SECRET in Render. Thanks Ashley for your help!
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
DR
What's the problem you're trying to solve?
Trying to deploy Django with React. Got React frontend deployed on Netlify, but I'm not sure how to connect the frontend with my backend.
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
Currently on bio.io and not able to see my data displaying in the dashboard.
Testing sign in on deployed frontend gets 404
What is your best guess as to the source of the problem?
The step in the guide for Django deployment instructs the reader to "Click on Connect then copy the Postgres Connection string." -- is there an equivalent of that step for a Netlify/React deploy?
What things have you already tried to solve the problem?
Reading docs on connecting a bit.io backend and netlify frontend, but still not sure where the right next move may be
Paste a link to your repository here https://github.com/caitreid/mp_frontend https://github.com/caitreid/mp_backend