Skip to content

Commit

Permalink
switch to vercel to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkE16 committed Nov 22, 2024
1 parent 6e5d569 commit cadb583
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
29 changes: 9 additions & 20 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy to Netlify
name: Build and Deploy to Vercel

on:
push:
Expand All @@ -10,24 +10,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install

- name: Build Project
run: pnpm run build

- name: Deploy to Netlify
uses: nwtgck/[email protected]
- name: Deploy to Vercel
uses: BetaHuhn/deploy-to-vercel-action@v1
with:
publish-dir: ./dist
production-branch: main
deploy-message: ${{ github.event.head_commit.message }}
github-token: ${{ secrets.GH_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
8 changes: 8 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rewrites": [
{
"source": "/((?!assets/).*",
"destination": "vercel/ssr.js"
}
]
}
22 changes: 22 additions & 0 deletions vercel/ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { renderPage } from "vite-plugin-ssr/server";

export default async function handler(req, res) {
const { url } = req;

if (!url) throw new Error("req.url is undefined");

const pageContextInit = { urlOriginal: url };
const pageContext = await renderPage(pageContextInit);
const { httpResponse } = pageContext;

if (!httpResponse) {
res.statusCode = 200;
res.end();
return;
}

const { body, statusCode, headers } = httpResponse;
res.statusCode = statusCode;
headers.forEach(([name, value]) => res.setHeader(name, value));
res.end(body);
}
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { UserConfig } from "vite";

const config: UserConfig = {
plugins: [react(), ssr()],
base: "/"
};

export default config;

0 comments on commit cadb583

Please sign in to comment.