Coder Social home page Coder Social logo

salihozdemir / stackoverflow-clone Goto Github PK

View Code? Open in Web Editor NEW
664.0 21.0 180.0 1.17 MB

This project is a simplified a full stack clone of Stackoverflow.

Home Page: https://clone-of-stackoverflow.vercel.app

License: MIT License

JavaScript 81.14% CSS 18.86%
nextjs react nodejs mongodb postcss moongose storybook context-api express

stackoverflow-clone's People

Contributors

dejvid98 avatar dependabot[bot] avatar salihozdemir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stackoverflow-clone's Issues

API does not verify JWT tokens

Problem

When you decode the provided JWT token to authorize the request, you're not checking whether the JWT token is genuine; that it was signed by you, and the contents are valid.

const decodedToken = jwtDecode(token.slice(7));
if (!decodedToken) {
return res.status(401).json({
message: 'There was a problem authorizing the request.'
});
} else {
req.user = decodedToken;
next();
}

This means that I could create my own token, pretending to be any user I like, and your server won't check to see if it's a forgery.

I could also create a token that contains { role: "admin" } and do whatever an admin can do:

if (req.question.author._id.equals(req.user.id) || req.user.role === 'admin') return next();

This is also a problem in your reddit-clone repo

Example

For example, this completely fake & unsigned JWT token I made myself:

e30.eyJpZCI6MSwidXNlcm5hbWUiOiJhbGljZSIsInJvbGUiOiJhZG1pbiJ9

Which contains this fake data:

{
    id: 1,
    username: "alice",
    role: "admin"
}

Would allow me to bypass your requireAuth middleware.

Documentation

The library you're using to do this (jwt-decode) has a large warning about this on its README:

jwt-decode is a small browser library that helps decoding JWTs token which are Base64Url encoded.

IMPORTANT: This library doesn't validate the token, any well formed JWT can be decoded. You should validate the token in your server-side logic by using something like express-jwt, koa-jwt, Owin Bearer JWT, etc.

Changing the name of the project

Hello,

First of all, "ellerine sağlık", the project is great!

I think changing the name into something else (maybe another error like segmentation fault to keep the joke) would be better, because this project may be easily turned into a self-hosted version of Stack Overflow (actually a self-hosted Q&A platform) and may be used by organizations or projects that need such solution.

Best regards,

Connect to atlas mongodb

I create the cluster, the user and then allowing all IPs to have access to my cluster. I press connect to get the application string and change the with my password leaving the default database myFirst Database. When I paste the string to the DATABASE_URL variable and then press deploy I get {"message":"Not found"}. What am I doing wrong?

How do you create this clone?

First Congratulations for your work, I'm trying to get better at front end and react. I'm trying to understand how is the process do you take when you clone?

Get Cors error while trying first setup

Seems server side not started successfully

Unhandled Runtime Error
Error: Network Error

Call Stack
createError
node_modules/axios/lib/core/createError.js (16:0)
XMLHttpRequest.handleError
node_modules/axios/lib/adapters/xhr.js (83:0)

a-nai@a-nai:~/stackoverflow-clone/server$ sudo npm run start

[email protected] start /home/a-nai/stackoverflow-clone/server
node index.js

at http://84.201.145.163:8080 i get
{"message":"Not found"}

Error: Request failed with status code 500

I try to test stackoverflow-clone on local with Linux, but I have this alert in the page, instead of the database content.

Screen Shot 2021-09-14 at 12 01 40 AM

Unhandled Runtime Error

Error: Request failed with status code 500
Call Stack
createError
node_modules/axios/lib/core/createError.js (16:0)
settle
node_modules/axios/lib/core/settle.js (17:0)
handleLoad
node_modules/axios/lib/adapters/xhr.js (61:0)

Setting basePath for Next

I am unable to get the application to use a basePath parameter supplied in the next.config.js file:

adding

module.exports = { basePath: '/somepath' ...

doesn't seem to have any effect

mongoose

DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version

Creating the same clone based on firebase

Hey there! I am new to programming and I know only firebase... Could you create the same clone ( all the files should be same) but only replace mongodb with firebase?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.