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 May 23, 2024
1 parent 9bd6622 commit 61f2079
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/presets/vercel/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 @@ -48,7 +48,7 @@ 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 @@ -88,7 +88,7 @@ const vercelStatic = defineNitroPreset(
extends: "static",
output: {
dir: "{{ rootDir }}/.vercel/output",
publicDir: "{{ output.dir }}/static",
publicDir: "{{ output.dir }}/static/{{ baseURL }}",
},
commands: {
preview: "npx serve ./static",
Expand Down
4 changes: 2 additions & 2 deletions src/presets/vercel/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fsp from "node:fs/promises";
import { dirname, relative, resolve } from "pathe";
import { writeFile } from "../_utils";
import { defu } from "defu";
import { withoutLeadingSlash } from "ufo";
import { joinURL, withoutLeadingSlash } from "ufo";
import type {
VercelBuildConfigV3,
VercelServerlessFunctionConfig,
Expand Down Expand Up @@ -121,7 +121,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 61f2079

Please sign in to comment.