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

How to hide access token without API proxy server

I'm trying to display images of Instagram on HTML page and deploy on a hosting website. I only know HTML, CSS and a bit of JS. I tried using the API proxy server by following youtube tutorial, but I'm getting a lot of errors. is there any way I can avoid that?...

Firestore security rules for objects inside of the array

Hi everyone! In my Firestore, I have a collection called "items" and there are couple of documents inside. Some of these documents have "reviews" property, which is created by arrayUnion() called from my front-end and the objects inside of this array always have 4 properties, one of them is userId. In my front-end, I'm sending a get request to get the whole reviews array, like this: doc.data().reviews. How can I write my security rules so that userId is never returned no matter what? I asked ChatGPT to help me write the rules, but these doesn't work:...

Create a list of links in PHP?

Hi, I have this page https://chrisbarin.com/membership-account/membership-checkout/?level=1 built in WordPress that's using a very tricky plugin. I have little development experience. I'm looking to replace those blue links which are automatically created with custom links and text. So I'd like to replace the code with something like <name> then <url> so that I can easily change both. Here's the entire code of that page in case it helps: https://pastebin.com/8ieDGPaD PS: I only need the blue links edited, not the array of benefits underneath....

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

Was working on a small blog type website in free time, heard MongoDB is decent for storing text content. Looked into it, went through CRUD and everything. When finally used it, ran into this error. I'm trying to store article content (title, date, author, body, img urls etc..) as json on atlas and using nth child to use it on webpage. When i use fetch in my js file to get data from the link i got from mongoDB connect page, it returns this error...

dotenv in production?

Anything wrong with using dotenv in production? i can't see anything to suggest there is, but thought I'd check given it's a security thing. Googling throws up an article outlining issues that don't really apply to me https://dev.to/gregorygaines/stop-using-env-files-now-kp0, but I've also seen an article countering that one 😄

Requests between webservers in Nginx

So I've got 2 servers up and running on my Nginx server. Both are working/routing correctly, and I've made one a subdomain of the other: api.example.com & example.com If I need to communicate between the two do I still just make a request to api.example.com? Is that request going out to the internet and then back to Nginx, or is there a way to tell Nginx just to make the request directly?...

`Cant install mongodb on mac`

I cant install Mongodb on my mac keeps failing with the error below

1st time picking up a database, require recommendations

Hello, I'm starting to learn a bit about the backend database and I been seeing RethinkDB, MongoDB, OrientDB, and many more. With so much to choose from, I want you guys to recommend me one as someone new to all of theses databases as you guys will know more about which one is better or easy to use for someone starting out like me. I would be using this with React.js so if there is one that works well with React I would prefer that. Thanks in advance 🙂...

Puppeteer (nodejs package): need help understanding page.evaluate & elementHandle.evaluate

Hello, Learning nodejs' puppeteer package for webscraping right now. Please, correct me, if I'm wrong: I believe evaluate, takes in a pageFunction, runs it against the calling object. The point of having those functions in those classes is that we can access members of that object in our callback and perform work with it (e.g. . Am I right on all of that ? ...

Classes repetitive

What's the best way to shorten/one class a multiple class/model? I have seen our line of codes repetitive a same class with just different class name but with same arguments inside. ``` ...

Artisan Problem

I'm trying to learn a little about laravel and was attempting their tutorial, but when I set up my project and ran: php artisan serve I get the following error: In PackageManifest.php line 177: The C:\Users\Ted\Documents\Web Development\PHP\laravel\chirper\bootstrap\cache directory must be present and writable. ...

More file structure, this time webpack flavoured!

Thought I'd make another thread as this is kind of a different, but very related, question I've been developing locally using webpack and vanillajs. My server is hosted on digitalocean with ubuntu. As mentioned in my last question I build locally, push to a github repo, and then pull that repo in to my server. I plan to use github actions from next week thanks to @joao6246 advice, but for the time being that's the (maybe less than ideal?) set-up I learnt from frontend masters My Server folder structure:...

File structure on my server

I've ubuntu running on a digital ocean droplet that I was planning on using to clone a github repo of mine that I use locally. In that repo I have my usual dev/build folder structure, so I can build locally, but that'll mean when I pull the repo from my server it'll have all the dev files. Just wondering if this matters, or if there's a better way to do it? Sorry if this seems simple, but this is my first time sorting my own server 🙂...

Scheduled code execution

If you need a piece of code to run at exactly x date at y time, but also another piece of code (like a reminder) some 10 or whatever minutes before that date...how would you accomplish that? Cron jobs? on your API code or a separate Cron service? Any other methods you would use? All ideas welcomed

Error when trying to create an image in Node js

```js function BW(){ let pixels=[]; for(let i=0;i<256;i++){ pixels.push(random(0,255))...

Error with pathing when using netlify

```Request from ::1: POST /.netlify/functions/api/shorten [Error: ENOENT: no such file or directory, open 'urls.json'] { errno: -2, code: 'ENOENT', syscall: 'open',...

Another (hopefully simple) passport question (passport.authenticate())

I'm following a great passport guide by a guy called zach gollwitzer - would really recommend: https://www.youtube.com/watch?v=F-sFp_AvHc8 He talks about using the ``` passport.authenticate('local', {failureRedirect: '/login-failure', successRedirect: 'login-success'})...

Deserializing a user with passportjs (promise chaining vs async await?)

I'm following a tutorial on passport and am looking at a deserializeUser function: ``` passport.deserializeUser((userId, done) => { User.findById(userId)...

Proxyquire with a nested dependency

So I've got a test file and 2 modules. moduleA has a dependency, moduleB ```// moduleA.js...

How to make SQL Table Column data UNIQUE

I created this Clubs table in my SQL database but I want to make name row unique such that two rows will not have the same name. ``CREATE TABLE clubs ( id integer PRIMARY KEY AUTO_INCREMENT, name` VARCHAR(45) NOT NULL,...