tszhong0411 / honghong.me

⚡ A monorepo of my personal website and blog built with TypeScript, Next.js, and Tailwind CSS
https://honghong.me
GNU General Public License v3.0
465 stars 72 forks source link

.Env Detail #551

Closed Rivalakmalll closed 8 months ago

Rivalakmalll commented 8 months ago

hi first i like ur source its cool but i have some issue to setup with env file i dont know my API right or wrong so can i get example and for the refresh token spotify how to i get it and umami database and some env requirement i dont know thx

tszhong0411 commented 8 months ago

@Rivalakmalll For the Spotify API, you can follow this great blog post. And the Umami database URL is set when setup umami and installation.

Example of .env:

NEXT_PUBLIC_GISCUS_REPO=tszhong0411/honghong.me
NEXT_PUBLIC_GISCUS_REPOSITORY_ID=R_kgDOGxHFnA
NEXT_PUBLIC_GISCUS_CATEGORY="Blog Comments"
NEXT_PUBLIC_GISCUS_CATEGORY_ID=DIC_kwDOGxHFnM4CBGIQ
SPOTIFY_CLIENT_ID=abcbs**********e22612093414fe5c5
SPOTIFY_CLIENT_SECRET=7c872f54c**********1a5231cc512h5
SPOTIFY_REFRESH_TOKEN=CBQ5-luYTuVHfkx3E8HyrkC**********xglKXaCaDPuW4GP39ItUanyHwS**********EOfp3asJitVoflhkDbY7y9IP**********Sp0Te14pOc8ERCDHb-k2jfKiJx-A

NEXTAUTH_SECRET=Rfgvgm7L**********ZwMPzuG1J**********8m73Gc
NEXTAUTH_URL=http://localhost:3000

GOOGLE_API_KEY=AIzaSyA**********JRyf5UZAQazUO9*****nZ8

OAUTH_CLIENT_KEY=eed0f9f**********607
OAUTH_CLIENT_SECRET=5b55**********035b7203de1bb7**********d3

GITHUB_TOKEN=ghp_**********muXVNLZYrUn4ir**********Xz

DATABASE_URL=mysql://root:@localhost:3306/blog

IP_ADDRESS_SALT="hello-world-hello-world"

WAKATIME_API_KEY=waka_948f0238-****-****-kl39-********b285

DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/********82672537751/********YKAPL4gQNz1m********JJomBo-zT7gXr2_*******-6ag9l6jl5Ob_*****

UMAMI_DATABASE_URL=mysql://*************:pscale_pw_****************************@aws.connect.psdb.cloud/umami?sslaccept=strict
NEXT_PUBLIC_UMAMI_URL=https://umami.honghong.me
NEXT_PUBLIC_UMAMI_WEBSITE_ID=4a113320-ef57-44cd-bc0e-08389b9ccae3
NEXT_PUBLIC_UMAMI_WEBSITE_SHARE_URL=https://umami.honghong.me/share/Qqay0bYutLX0pORg/blog
Devzjta commented 8 months ago

Hi, Rivalakmalll question was also mine. Taking advantage, where can I get these APIs?


NEXTAUTH_SECRET=Rfgvgm7L**********ZwMPzuG1J**********8m73Gc
NEXTAUTH_URL=http://localhost:3000

and

OAUTH_CLIENT_KEY=eed0f9f**********607
OAUTH_CLIENT_SECRET=5b55**********035b7203de1bb7**********d3
Rivalakmalll commented 8 months ago

hi thx for answer my issue im alrd can run it but i got this in logs

⨯ PrismaClientKnownRequestError: [1] Invalid prisma.post.findUnique() invocation: [1] [1] [1] The table post does not exist in the current database. [1] at Cn.handleRequestError (D:\honghong.me-main\node_modules\@prisma\client\runtime\library.js:123:6817) [1] at Cn.handleAndLogRequestError (D:\honghong.me-main\node_modules\@prisma\client\runtime\library.js:123:6206) [1] at Cn.request (D:\honghong.me-main\node_modules\@prisma\client\runtime\library.js:123:5926) [1] at l (D:\honghong.me-main\node_modules\@prisma\client\runtime\library.js:128:9968) [1] at async Promise.all (index 0) [1] at GET (webpack-internal:///(rsc)/./src/app/api/likes/route.ts:39:26) [1] at D:\honghong.me-main\node_modules\next\dist\compiled\next-server\webpack:\next\dist\esm\server\future\route-modules\app-route\module.js:191:37 { [1] code: 'P2021', [1] clientVersion: '5.4.2', [1] meta: { table: 'post' } [1] }

tszhong0411 commented 8 months ago

@Devzjta For the next auth environment variables, you need to set NEXTAUTH_SECRET and NEXTAUTH_URL. And the OAUTH variables are used for GitHub authentication.

That I mentioned in .env.example Github OAuth https://github.com/settings/applications/new

tszhong0411 commented 8 months ago

@Rivalakmalll You need to run prisma db push to create the tables automatically. For more information https://www.prisma.io/docs/guides/migrate/prototyping-schema-db-push#prototyping-a-new-schema

Rivalakmalll commented 8 months ago

Thx i will try it appreciate it

Rivalakmalll commented 8 months ago

hei sorry for asking too many i have more issue like this

⨯ src\app\api\wakatime\route.ts (21:12) @ total_seconds [1] ⨯ Cannot read properties of undefined (reading 'total_seconds') [1] 19 | [1] 20 | const { [1] > 21 | data: { total_seconds } [1] | ^ [1] 22 | } = await res.json() [1] 23 | [1] 24 | return NextResponse.json({

and my dashboard no sync but im alrd put the API same like example before with my API

thx

tszhong0411 commented 8 months ago

@Rivalakmalll Check out the code here wakatime/route.ts. If your API key is not valid or there is no data (maybe), there is no 200 response. Try to log the response and debug it.

Rivalakmalll commented 8 months ago

Hi i need to know how to change the copyright © 2023 i cant find it on code thx

tszhong0411 commented 8 months ago

@Rivalakmalll The footer is written here.

Thank you for your interest in my project. I'd like to clarify that this code isn't intended to be used as a template for websites but rather as a learning resource and source of inspiration. Please refer to the README.md for more details on this.

It's important to note that my code is released under the GNU Affero General Public License (GNU AGPL), which means there are specific requirements and responsibilities associated with its usage and distribution. Please make sure to comply with the terms of the license if you choose to use or adapt the code for your project.

If you're looking to build a website, I'd recommend exploring Next.js and React. They are great technologies to learn and can help you create dynamic and interactive web applications.

Rivalakmalll commented 8 months ago

Hi thx i appreciate it anw i need more know to publish this website to vercel how i do vercel did i must add .env too in vercel deploy page?

tszhong0411 commented 8 months ago

@Rivalakmalll I recommend starting by watching some tutorial videos and reading documentation on both Vercel and Next.js. This will help you understand the fundamentals and best practices. While I'm here to offer guidance, I want to reiterate that it's best to use my code as a learning resource and not as a direct template for your project. This way, you can develop your skills and create something unique.

Rivalakmalll commented 8 months ago

Ok thx and i appreciate it