Skip to content

Commit

Permalink
fix(vercel): support custom baseURL (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored and pi0 committed Jun 27, 2024
1 parent bb98df9 commit 50504ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/presets/vercel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fsp from "node:fs/promises";
import { dirname, relative, resolve } from "pathe";
import { defu } from "defu";
import { withoutLeadingSlash } from "ufo";
import { withoutLeadingSlash, joinURL } from "ufo";
import { writeFile } from "../utils";
import { defineNitroPreset } from "../preset";
import type { Nitro } from "../types";
Expand All @@ -18,7 +18,7 @@ export const vercel = defineNitroPreset({
output: {
dir: "{{ rootDir }}/.vercel/output",
serverDir: "{{ output.dir }}/functions/__nitro.func",
publicDir: "{{ output.dir }}/static",
publicDir: "{{ output.dir }}/static/{{ baseURL }}",
},
commands: {
deploy: "",
Expand Down Expand Up @@ -87,7 +87,7 @@ export const vercelEdge = defineNitroPreset({
output: {
dir: "{{ rootDir }}/.vercel/output",
serverDir: "{{ output.dir }}/functions/__nitro.func",
publicDir: "{{ output.dir }}/static",
publicDir: "{{ output.dir }}/static/{{ baseURL }}",
},
commands: {
deploy: "",
Expand Down Expand Up @@ -196,7 +196,7 @@ function generateBuildConfig(nitro: Nitro) {
// Public asset rules
...nitro.options.publicAssets
.filter((asset) => !asset.fallthrough)
.map((asset) => asset.baseURL)
.map((asset) => joinURL(nitro.options.baseURL, asset.baseURL || "/"))
.map((baseURL) => ({
src: baseURL + "(.*)",
headers: {
Expand Down

0 comments on commit 50504ab

Please sign in to comment.