krharsh17 / descope-qna

1 stars 0 forks source link

Updates on the Add Auth to a React app with Descope #1

Open kashvipahuja opened 1 month ago

kashvipahuja commented 1 month ago

Hi Harsh, there are a few changes that need to made to this blog in terms of the code for the sample app and the content of the blog as well. Mainly the issues are some error catches and try catch blocks - as well as a command to run the frontend of the app as that was missed. Additionally I also added the neon script in case users decide to use neon instead of their local postgres, as the neon environment does not accept the same script.

For example, here is a small snippet of code that was added into the postgres function to avoid console errors and an explanation as to why ssl was needed:

                const sql = postgres({
                    host: process.env.PGHOST,            // Postgres ip address[s] or domain name[s]
                    port: process.env.PGPORT,                   // Postgres server port[s]
                    database: process.env.PGDATABASE,             // Name of database to connect to
                    username: process.env.PGUSER,             // Username of database user
                    password: process.env.PGPASSWORD,             // Password of database user
                ssl: {
                       rejectUnauthorized: false // Adjust as needed for SSL settings
                   }

                })
                The rejectUnauthorized: false setting is used in this code to allow the PostgreSQL client to connect to the database even if the SSL certificate presented by the server cannot be verified. 

Is it okay with you if I add you to the document with the suggested changes? This way you can update the code on your repo as well? I found your email on your github profile: hey@kumarharsh.me Let me know if this is okay with you.

krharsh17 commented 1 month ago

Hey Kashvi,

Thanks for reaching out. Please feel free to update the blog as you'd like and then let me know; I'll make the necessary changes here in the repo as well.

Alternatively, you could fork this repo, make the changes, and then create a PR if you'd like to take care of repo changes yourself as well.

Best, Kumar

kashvipahuja commented 1 month ago

Thanks for your response! The blog has been changed, so just the changes to the repo are required on your part. I will add you to the doc and you can see the code changes highlighted as comments.

krharsh17 commented 2 weeks ago

Hey Kashvi, thanks for sharing the doc with me and sorry for the late response; I was busy with some family stuff for most of August. I will update the repo and let you know as soon as it is done.

krharsh17 commented 2 weeks ago

@kashvipahuja I have updated the repo code to match the code snippets in the tutorial here: https://www.descope.com/blog/post/react-authentication-tutorial Please review and let me know if anything else needs to be changed

Two points for you to note:

  1. This is a stray line in a code snippet: https://www.descope.com/blog/post/react-authentication-tutorial#:~:text=The%20rejectUnauthorized%3A%20false%20setting%20is%20used%20in%20this%20code%20to%20allow%20the%20PostgreSQL%20client%20to%20connect%20to%20the%20database%20even%20if%20the%20SSL%20certificate%20presented%20by%20the%20server%20cannot%20be%20verified. I guess this was supposed to be a comment. If so, please add // at the beginning of the line
  2. This could use better formatting: https://www.descope.com/blog/post/react-authentication-tutorial#:~:text=ssl%3A%20%7B%0A%20%20%20%20%20%20%20rejectUnauthorized%3A%20false%20//%20Adjust%20as%20needed%20for%20SSL%20settings%0A%20%20%20%7D Also, this breaks the app in the case of a local postgres setup (I'm using the Postgre app for Mac, and it throws an ECONNRESET if add that line. Please review and update that if needed