forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix github stars endpoint (twentyhq#5301)
- Encapsulated GitHub star response in an object - Fixed rounding of Github stars to align with Github convention - Fixed CORS issue so that endpoint can be called from twenty.com and app.twenty.com Co-authored-by: Ady Beraud <[email protected]>
- Loading branch information
1 parent
a2017ea
commit b438fc2
Showing
3 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
const allowedOrigins = [ | ||
'http://localhost:3000', | ||
'https://app.twenty.com', | ||
'https://twenty.com', | ||
]; | ||
|
||
export function middleware(req: any) { | ||
const res = NextResponse.next(); | ||
|
||
const origin = req.headers.get('origin'); | ||
|
||
if (allowedOrigins.includes(origin)) { | ||
res.headers.append('Access-Control-Allow-Origin', origin); | ||
} | ||
|
||
res.headers.append('Access-Control-Allow-Credentials', 'true'); | ||
res.headers.append( | ||
'Access-Control-Allow-Methods', | ||
'GET,DELETE,PATCH,POST,PUT', | ||
); | ||
res.headers.append( | ||
'Access-Control-Allow-Headers', | ||
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version', | ||
); | ||
|
||
return res; | ||
} | ||
|
||
export const config = { | ||
matcher: '/api/:path*', | ||
}; |
2 changes: 1 addition & 1 deletion
2
packages/twenty-website/src/shared-utils/formatNumberOfStars.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const formatNumberOfStars = (numberOfStars: number) => { | ||
return Math.floor(numberOfStars / 100) / 10 + 'k'; | ||
return Math.ceil(numberOfStars / 100) / 10 + 'k'; | ||
}; |