mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
feat: rewrite api on dev
This commit is contained in:
parent
fdf7dc66c5
commit
ce4d8ae5ff
2 changed files with 11 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ import type { AxiosError } from 'axios';
|
|||
|
||||
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
||||
|
||||
export const API_URL = 'http://localhost:8000';
|
||||
export const API_URL = '/api';
|
||||
|
||||
export interface ApiError {
|
||||
error: AxiosError | unknown;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,16 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
|||
import type { UserConfig } from 'vite';
|
||||
|
||||
const config: UserConfig = {
|
||||
plugins: [sveltekit()]
|
||||
plugins: [sveltekit()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
|||
Loading…
Reference in a new issue