Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
In Sveltekit & Vite... How to proxy/hide the folder "api"? Works local but not in Vercel

I'm using sveltekit, when the customers request:

https://example.com/v1/contacts

I would like to be pointing internally to:

https://example.com/api/v1/contacts

*This way I can have a much better cleaner organization in my code.

This is my vite.config.js:

import { sveltekit } from '@sveltejs/kit/vite';

/** @type {import('vite').UserConfig} */
const config = {
    plugins: [sveltekit()],
    server: {
        port: 3001
        proxy: {
            '/v1': {
                target: 'http://127.0.0.1:3001/',
                secure: false,
                changeOrigin: true,
                rewrite: (path) => {
                    return 'api/' + path;
                }
            }
        }
    },
    preview: {
        port: 3001
    }
};

export default config;

It works in localhost, npm run dev, and in localhost when I do npm run preview, but when I upload it to Vercel, it doesn't work. Any ideas?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!