Skip to content

Commit

Permalink
Vercel Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpacaFur committed Apr 7, 2024
1 parent fa49185 commit f7bd8be
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
19 changes: 16 additions & 3 deletions packages/api-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,29 @@ class APIClient {
params?: any,
headers?: any
): Promise<T> {
const deployedURL = `${window.location.protocol}//api.${window.location.hostname}/api`;
const localhostURL = "/api";
const baseURL =
window.location.hostname === "localhost" ? localhostURL : deployedURL;

const reqURL = baseURL + url;

const res = (
await this.axios.request({ method, url, data: body, params, headers })
await this.axios.request({
method,
url: reqURL,
data: body,
params,
headers,
})
).data;
return responseClass ? plainToInstance(responseClass, res) : res;
}

constructor(baseURL = "/api") {
constructor() {
this.axios = Axios.create({
baseURL: baseURL,
headers: { "content-type": "application/json" },
withCredentials: true,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: graduateLogger,
cors: {
origin: "https://frontend-staging.graduatenu.com",
origin: /graduatenu.com$/,
credentials: true,
methods: ["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"],
},
Expand Down
5 changes: 5 additions & 0 deletions packages/frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
const nextConfig = {
reactStrictMode: true,
output: "standalone",
experimental: {
// this will allow nextjs to resolve files (js, ts, css)
// outside packages/app directory.
externalDir: true,
},
};

module.exports = nextConfig;
1 change: 1 addition & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@fontsource/montserrat-alternates": "^4.5.9",
"@graduate/api-client": "workspace:*",
"@graduate/common": "workspace:*",
"framer-motion": "^6",
"immer": "^9.0.15",
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3076,7 +3076,7 @@ __metadata:
languageName: node
linkType: hard

"@graduate/api-client@workspace:packages/api-client":
"@graduate/api-client@workspace:*, @graduate/api-client@workspace:packages/api-client":
version: 0.0.0-use.local
resolution: "@graduate/api-client@workspace:packages/api-client"
dependencies:
Expand Down Expand Up @@ -3157,6 +3157,7 @@ __metadata:
"@emotion/react": ^11
"@emotion/styled": ^11
"@fontsource/montserrat-alternates": ^4.5.9
"@graduate/api-client": "workspace:*"
"@graduate/common": "workspace:*"
"@types/eslint": ^8
"@types/node": 17.0.23
Expand Down

0 comments on commit f7bd8be

Please sign in to comment.