8 changed files with 50 additions and 8 deletions
+32
View File
@@ -0,0 +1,32 @@
# wegoze portal deployment (sub-path: /dashboards/vrachtwagenheffing)
# Self-contained copy of ./Dockerfile with the base path baked in at build time.
# The standalone deployment keeps using ./Dockerfile and is unaffected.
#
# NEXT_PUBLIC_BASE_PATH is inlined at build time (Next.js), so every asset and
# data URL becomes /dashboards/vrachtwagenheffing/... . `next start` re-reads next.config.mjs at runtime,
# so the variable must be present there too.
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
ENV NEXT_PUBLIC_BASE_PATH=/dashboards/vrachtwagenheffing
RUN npm run build
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV NEXT_PUBLIC_BASE_PATH=/dashboards/vrachtwagenheffing
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.mjs ./next.config.mjs
EXPOSE 3000
CMD ["npm", "run", "start"]
+1 -1
View File
@@ -215,7 +215,7 @@ export default function ApiDocsPage() {
<h1 className="text-lg font-bold text-gray-900">API Documentatie</h1>
<span className="text-xs text-gray-400">OpenAPI 3.0</span>
<a
href="/api/v1/openapi"
href={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/api/v1/openapi`}
target="_blank"
className="ml-auto text-xs text-brand-600 hover:underline"
>
+4 -1
View File
@@ -33,6 +33,9 @@ export default function Home() {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
// Portal sub-path support: empty for the standalone deployment, set at build
// time for the wegoze portal (e.g. "/dashboards/vrachtwagenheffing").
const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH || '';
const [showAbout, setShowAbout] = useState(false);
const [showData, setShowData] = useState(false);
@@ -43,7 +46,7 @@ export default function Home() {
useEffect(() => {
setLoading(true);
fetch('/data/toll-network.geojson')
fetch(`${BASE_PATH}/data/toll-network.geojson`)
.then(async (res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
+1 -1
View File
@@ -156,7 +156,7 @@ export default function DataModal({ open, onClose, data }: DataModalProps) {
<ApiRow method="POST" path="/api/v1/toll-network/calculate" />
</div>
<a
href="/api/v1/docs"
href={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/api/v1/docs`}
className="inline-flex items-center gap-1 text-xs font-medium text-brand-700 hover:underline"
>
<ExternalLink className="w-3 h-3" />
+2 -2
View File
@@ -84,7 +84,7 @@ export default function SidePanel({
setCalcError(null);
try {
const res = await fetch('/api/v1/toll-network/calculate', {
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/api/v1/toll-network/calculate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -539,7 +539,7 @@ function VehicleCard({
setRdw(null);
try {
const res = await fetch(`/api/v1/rdw/${encodeURIComponent(kenteken.trim())}`);
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/api/v1/rdw/${encodeURIComponent(kenteken.trim())}`);
if (!res.ok) {
const data = await res.json().catch(() => null);
throw new Error(data?.error || `Fout ${res.status}`);
+4 -2
View File
@@ -16,9 +16,11 @@ const NL_BOUNDS: L.LatLngBoundsExpression = [
[53.47, 7.21],
];
const TILE_URL = 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png';
// CARTO's raster basemaps now require an API key; without one every tile is
// watermarked 'API KEY REQUIRED'. OpenStreetMap's standard tiles need no key.
const TILE_URL = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
const TILE_ATTRIBUTION =
'&copy; <a href="https://www.openstreetmap.org/copyright">OSM</a> &copy; <a href="https://carto.com/">CARTO</a>';
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
function MapController({
data,
+5
View File
@@ -1,5 +1,10 @@
/** @type {import('next').NextConfig} */
// Opt-in sub-path support: empty for standalone/root deployments (unchanged),
// set to e.g. "/dashboards/vrachtwagenheffing" at build time for the wegoze portal.
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
const nextConfig = {
...(basePath ? { basePath } : {}),
async headers() {
return [
{
File diff suppressed because one or more lines are too long