Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Migrate to NextJS
Browse files Browse the repository at this point in the history
- Update `.env` file to convert VITE to NEXT_PUBLIC
- IMPORTANT: `.env` files will need to be updated to reflect this,
  please check the .env.example for more information. Referencing
  variables will not work for anything used in NextJS as it is loaded
  through `dotenv` (so we can use `.env` in parent directory), which
  does not seem to work with variable references (such as jddAqAqAq`A=$B`)q
- Restructured code to work with NextJS
- Fixed bug with tailwind: vercel/next.js#34448 (comment)
- Added dependencies (`dotenv`, `eslint-config-next`, `next`)
  • Loading branch information
jacob-horton committed Jun 15, 2023
1 parent 93b7b4d commit 2450a1d
Show file tree
Hide file tree
Showing 25 changed files with 6,152 additions and 2,094 deletions.
13 changes: 8 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ DATABASE_URL=postgres://$DBUSER:$DBPASSWORD@$DBADDR:5433/$DBNAME


#### AUTHENTICATION ####
AUTHURL=http://localhost:8180/auth/realms/flipster
JWKS_URL=$AUTHURL/protocol/openid-connect/certs
VITE_AUTH_SERVER_URL=$AUTHURL
JWKS_URL=http://localhost:8180/auth/realms/flipsterprotocol/openid-connect/certs
NEXT_PUBLIC_AUTH_URL=http://localhost:8180/auth/realms/flipster

# Needs to be configured in keycloak
VITE_AUTH_CLIENT_ID="react-auth"
NEXT_PUBLIC_AUTH_CLIENT_ID="react-auth"


#### Next JS ####
NEXT_PUBLIC_URL=http://localhost:5173


#### API ####
VITE_API_URL=http://localhost:8080
NEXT_PUBLIC_API_URL=http://localhost:8080


#### KEYCLOAK ####
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ sketch

**/*.env
data
.next
2 changes: 1 addition & 1 deletion api/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async fn get_sub(token: &str) -> Result<String, Box<dyn Error>> {
let decoding_key = DecodingKey::from_rsa_components(&jwk.n, &jwk.e)?;
let token = decode::<Claims>(token, &decoding_key, &Validation::new(Algorithm::RS256))?;

if token.claims.iss != env::var("VITE_AUTH_SERVER_URL").expect("No auth server URL provided") {
if token.claims.iss != env::var("NEXT_PUBLIC_AUTH_URL").expect("No auth server URL provided") {
return Err(Box::new(InvalidIssuer));
}

Expand Down
13 changes: 13 additions & 0 deletions web/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
13 changes: 0 additions & 13 deletions web/index.html

This file was deleted.

6 changes: 6 additions & 0 deletions web/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
3 changes: 3 additions & 0 deletions web/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { config } from "dotenv";

config({ path: "../.env" });
Loading

0 comments on commit 2450a1d

Please sign in to comment.