Kevin Powell - Community

KPC

Kevin Powell - Community

A friendly place for developers to meet other devs, ask questions, get help, and just have a good time šŸ™‚.

Join

front-end

resources

back-end

ui-ux

os-and-tools

Authentication with separate frontend and backend

Hi, I've had some attempts at creating a car marketplace app using React as frontend framework and Express on backend, but I dont know how to approach authentication. I don't want to use JWT's like every tutorial does, it seems to be exaggeration for my case. I've also tried using Spring for backend, but it's too complex. So, the question is: how to integrate frontend and backend session, so data is consistent(for example, when user changes name, the react app updates it). ...

Socket.io on backend and socket.io client on react front end issue

```js // front end import { io } from "socket.io-client"; const socket = io("http://localhost:3000");...

Multi-tenancy

Hello good folks. The purpose of this question is to get insight from the more experienced community. I'm trying to build a B2B system with data isolation concerns. For now, I chose to go with a schema-per-tenant data partition strategy. All tenants will share a common set of tables attached to their schema. But, the problem with this approach is the schema managment. To change even a single column across all schemas when you have many tenants is a challenge. I've tried an approach where I use drizzleORM to generate the "template" migration scripts. Then when a request comes in, I read the sql content from the file and replace the placeholder with the tenant's schema name. This works fine for creating new tenants. But the real problem now is global updates. I've not found a reliable way to do this so far....

Connect.sid in express using express-session

connect.sid in express session refreshes when I reload page, why... the id is same but just when timeout is reached, the connect.sid is destroyed but if I refresh page, it is regenerated, is that normal behaviour ?

Cookies not stored in postman when we use the front-end

I'm testing user session using postman. When I use postman to log in, a session is created and a cookie is stored. When I try to use the front-end to login, the cookie is created but isn't stored in postman, is this normal ?

Understanding sessions in express

Hello guys, sorry to disturb you all; I'm currently learning about managing sessions in express and I came across 2 properties: resave and saveUninitialized. I didn't understand these 2 properties; where and why do we use them? What does they do? From what I have understand, resave prevents the session from storing data for each request in our store (but what if we don't use a store? Like in my case; when is a store needed?) while saveUninitialized just makes sure that we create a cookie...

When creating a sign out route, should post or get request be used? why ?

Hello guys, sorry to disturb you all, I want to create a sign out route in my express server. I was reading a bit and saw that nowadays post request are used instead of get request which we used back in 2010. My question is why has this changed, why post is now used, I know the simple answer is "for security" but what exactly happens when using get or post to sign out a user, how post will handle it in a different way compared to get please

Getting an error when resending the get request

When i send the request first time it works fine but when i send the request second time it says " Error fetching project: TypeError: The "config.server" property is required and must be of type string." ```my-project/ ā”œā”€ā”€ config/...

Are there any free API to be consumed for a simple chatbot

Are there any free api that can be use to create a simple chatbot please... I was told the openai api should be paid, even if we are using the gpt 3.5 turbo model

Bearer token vs API key

Hello guys, sorry to disturb you all; is there a difference between a bearer token and an API key? From what I have understand, both a bearer token and an API key is kind of an "access card" that grants us access....

What is the purpose of API keys when it comes to third party apis

Hello guys, sorry to disturb you all; I started to learn the concept of APIs etc and I'm pretty conformtable with that term now especially the request-respond cycle. My question is, I saw that we have "API keys" what does that mean, when do we need them please. The idea of apis remain the same in the sense that it's just a request-respond cycle but what do we mean by "consume that api key" , then based on apis, we have documentations for specific one etc, I'm a bit confused here, how does it work, do we fetch the api from the back-end? Would really appreciate if someone can elaborate giving simple example please...

Struggling to deploy GitHub Repo to Railway

error sending request for url (https://backboard.railway.app/project/d55a4b99-fb 26-4971-81ae-e09307c9e643/environment/5697ba5d-d286-4b03-a795-739035a4333d/up?se rviceId=e1a988eb-ac39-4bf6-bae5-fceeb6499d0d) Caused by:...

POST operation vs DELETE operation

Hello guys, sorry to disturb you all; I was just experimenting some CRUD operations in mongoDB and I needed to remove a particular thing from the database. What I did is that I send a POST request having in my req.body whatever thing I need to remove. The confusion that arise is that, notice that I want to DELETE something but I use a POST request; it works fine, the thing is we can use both POST or DELETE, what is the difference then please...

AAPanel

Anyone can help me to connect PostGresql on AAPanle vps? i can use postgresql on my local machine easily.

How to link a post created from the front-end to the back-end to handle comments

Hello guys, sorry to disturb you all; I need to store comments for posts in my project. My database, mongoDB, has a post collection and in that collection, I will have an array "comments" which will store the comments for that particular post. The problem is how do I identify the post from the front-end correspond to that post on my database? The idea I first have is to identify the post by its title. The thing is title is not necessarily unique, so there might be some conflicts here. Does anyo...

Why did we use a .catch() rather than a catch() block while handling errors

Hello guys, can someone explain why in the following code, we use a .catch outside the function body that is when the function run is being called. Why don't we use a catch block directly after the try ? If we don't use a catch block inside, then what's the need of the try, we can remove it ? From what I have understand, this is why we might want to use a .catch() outside the function body rather than inside: we don't want the flow inside the function to stop every time there is an error with our return promises, instead of handling each error 1 at a time, let's just handle it at an upper level, that is when we call the function...

Why webpage refresh when we submit form with an image uploaded

Hello guys, I want a page to submit data without reloading. So I use the event.preventDefault() on my form and use the fetch API to send a request to my server. When I submit text fields only, like no image uploaded, I get the correct response and the web page isn't refresh. Now when I try to upload an image, I receive the response, a success response but the web page reloaded immediately, like as soon as response is sent, the web page is refresh, does someone know why please? The problem is surely because of the file upload because it only occur with the file being uploaded to the server. ```JS import express from 'express'; import path from 'path';...

How to send file uploaded back to web app, like uploading a profile picture

Hello guys, I need to upload a picture on a website, like uploading a profile picture. What I first did is to send the image to an upload folder in my local server. Then how should I proceed to actually load and save that image on the website please
Next