Git Product home page Git Product logo

dev_overflow_nextjs13's Introduction

Dev Overflow - A problem solving community

demo

๐ŸŒ Demo

Here is a working live demo: https://dev-overflow-nextjs13-rakibtweets.vercel.app/

๐Ÿ“ Description

Welcome to my project! Here, I'll provide you with a brief overview of what inspired me to create it, why it solves a problem, and what I've learned throughout its development.

  • Motivation: I was motivated to build this project to address a specific issue and to enhance my coding skills.
  • Why I Built This Project: My main goal was to create a practical and user-friendly solution to a real-world problem.
  • Problem Solved: This project aims to simplify a particular task, making it more efficient and accessible.
  • What I Learned: Throughout the development process, I gained valuable insights into various technologies and programming concepts.

๐Ÿ“– Table of Contents (Optional)

If your README is long, add a table of contents to make it easy for users to find what they need.

๐Ÿ› ๏ธ Setup Project

To get this project up and running in your development environment, follow these step-by-step instructions.

๐Ÿด Prerequisites

We need to install or make sure that these tools are pre-installed on your machine:

  • NodeJS: It is a JavaScript runtime build.

  • Git: It is an open source version control system.

โœจ Features

If your project has a lot of features, list them here.

๐Ÿš€ Install Project

  1. Clone the Repository
git clone https://github.com/rakibtweets/dev_overflow_nextjs13.git
  1. Install packages
npm install
  1. create a .env file add necessary credencitals
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
NEXT_PUBLIC_CLERK_SIGN_IN_URL=
NEXT_PUBLIC_CLERK_SIGN_UP_URL=
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=
NEXT_CLERK_WEBHOOK_SECRET=
NEXT_PUBLIC_TINY_EDITOR_API_KEY=
MONGODB_URL=
NEXT_PUBLIC_SERVER_URL=
OPENAI_API_KEY=
NEXT_PUBLIC_RAPID_API_KEY=
  1. Run the project using command below
npm run dev

โš’๏ธ How to Contribute

Want to contribute? Great!

To fix a bug or enhance an existing module, follow these steps:

  • Fork the repo
  • Create a new branch (git checkout -b improve-feature)
  • Make the appropriate changes in the files
  • Add changes to reflect the changes made
  • Commit your changes (git commit -am 'Improve feature')
  • Push to the branch (git push origin improve-feature)
  • Create a Pull Request

๐Ÿ“ฉ Bug / Feature Request

If you find a bug (the website couldn't handle the query and / or gave undesired results), kindly open an issue here by including your search query and the expected result.

If you'd like to request a new function, feel free to do so by opening an issue here. Please include sample queries and their corresponding results.

โœ… To-do

  • Enable users to save jobs to their favorites list.
  • Allow users to apply to a job directly from the app.
  • Provide a simple and intuitive user interface for easy navigation.
  • Allow users to filter jobs based on job title, location, or company.

๐Ÿ“ž Contact Us

Follow us on LinkedIn

Project Page Screenshoots

Feature pages

Home page ย  Global-search

All users ย  Tags page

profile ย 

dev_overflow_nextjs13's People

Contributors

rakibtweets avatar

Stargazers

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

Watchers

 avatar

dev_overflow_nextjs13's Issues

401 Unauthorised when processing a Clerk Webhook in Next.js

bro can u tell me how did u resolve this issue?
0

when i sync clerk data to my back end using webhook and do all steps i recive 401 error on vercel Log

this is app/api/webhook/route.ts

/* eslint-disable camelcase */
import { Webhook } from "svix";
import { headers } from "next/headers";
import { WebhookEvent } from "@clerk/nextjs/server";
import { createUser, updateUser, deleteUser } from "@/lib/actions/user.action";
import { NextResponse } from "next/server";

export async function POST(req: Request) {
// You can find this in the Clerk Dashboard -> Webhooks -> choose the webhook
// TODO: add your webhook secret to .env.loca
const WEBHOOK_SECRET = process.env.WEBHOOK_SECRET;

if (!WEBHOOK_SECRET) {
throw new Error(
"Please add WEBHOOK_SECRET from Clerk Dashboard to .env or .env.local"
);
}

// Get the headers
const headerPayload = headers();
const svix_id = headerPayload.get("svix-id");
const svix_timestamp = headerPayload.get("svix-timestamp");
const svix_signature = headerPayload.get("svix-signature");

// If there are no headers, error out
if (!svix_id || !svix_timestamp || !svix_signature) {
return new Response("Error occured -- no svix headers", {
status: 400,
});
}

// Get the body
const payload = await req.json();
const body = JSON.stringify(payload);

// Create a new Svix instance with your secret.
const wh = new Webhook(WEBHOOK_SECRET);

let evt: WebhookEvent;

// Verify the payload with the headers
try {
evt = wh.verify(body, {
"svix-id": svix_id,
"svix-timestamp": svix_timestamp,
"svix-signature": svix_signature,
}) as WebhookEvent;
} catch (err) {
console.error("Error verifying webhook:", err);
return new Response("Error occured", {
status: 400,
});
}

// Get the event type
const eventType = evt.type;

console.log({ eventType });

// Handle the event
if (eventType === "user.created") {
const { id, email_addresses, image_url, username, first_name, last_name } =
evt.data;

// Create a new user in your database
const mongoUser = await createUser({
  clerkId: id,
  name: `${first_name}${last_name ? ` ${last_name}` : ""}`,
  username: username!,
  email: email_addresses[0].email_address,
  picture: image_url,
});

return NextResponse.json({ message: "OK", user: mongoUser });

}

if (eventType === "user.updated") {
const { id, email_addresses, image_url, username, first_name, last_name } =
evt.data;

// Update a user in database
const mongoUser = await updateUser({
  clerkId: id,
  updateData: {
    name: `${first_name}${last_name ? ` ${last_name}` : ""}`,
    username: username!,
    email: email_addresses[0].email_address,
    picture: image_url,
  },
  path: `/profile/${id}`,
});

return NextResponse.json({ message: "OK", user: mongoUser });

}

if (eventType === "user.deleted") {
const { id } = evt.data;

// Delete a user in database
const deletedUser = await deleteUser({ clerkId: id! });

return NextResponse.json({ message: "OK", user: deletedUser });

}

return new Response("", { status: 200 });
}

middleware.ts

import { authMiddleware } from "@clerk/nextjs";

export default authMiddleware({
publicRoutes: [
"/",
"/api/webhook",
"question/:id",
"/tags",
"/tags/:id",
"/profile/:id",
"/community",
"/jops",
],
ignoredRoutes: ["/api/webhook", "/api/chatgpt"],
});

export const config = {
matcher: ["/((?!.+\.[\w]+$|_next).)", "/", "/(api|trpc)(.)"],
};

after deploy my app in vercel and copy url on clerk endpoint then clerk faild and i get 401 [post] api/webhook

what shoud i do to solve this 401 warnning

i try to change ignoredRoutes once i add it and delete it, once change webhooksecret in .envlocal and add env variables on vercel and re-deploy and nothing change

Screenshot 2024-01-09 at 1 52 48โ€ฏAM

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.