Skip to content

Commit

Permalink
fix: 修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanEichDisciple committed Oct 14, 2024
1 parent d3a7303 commit 16e91ba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
q.set('longitude', lng.toString());
q.set('latitude', lat.toString());
q.set('radius', radius.toString());
const response = await api.get(`hospitals?${q}`, {
const response = await api.get(`hospitals/circle?${q}`, {
headers: {
'Content-Type': 'application/json'
}
Expand Down
5 changes: 3 additions & 2 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import adapter from '@sveltejs/adapter-node';
import dotenv from 'dotenv';

// 加载环境变量
dotenv.config();
dotenv.config({ path: '.env.development' });
// console.log(process.env); // 检查 VITE_BASE 是否正确加载

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand All @@ -13,7 +14,7 @@ const config = {
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
paths: {
base: process.env.VITE_BASE || '/hospital'
base: process.env.VITE_BASE
}
}
};
Expand Down
15 changes: 13 additions & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ export default defineConfig(({ mode }) => {
plugins: [sveltekit()],
server: {
proxy: {
// 代理 '/api/v1/hospitals' 请求到目标地址
'/api/v1': 'http://localhost:3000',
'/api/v1': {
target: 'http://localhost:3000',
changeOrigin: true,
configure: (proxy, options) => {
// proxy 是 'http-proxy' 的实例
proxy.on('proxyReq', (proxyReq, req, res) => {
// proxyReq is the proxy request object from 'http-proxy'
// req and res are the original request and response objects from the client
// You can modify proxyReq here if needed
// console.log('proxyReq:', options);
});
}
},
'/_AMapService/': {
target: 'https://restapi.amap.com/',
changeOrigin: true,
Expand Down

0 comments on commit 16e91ba

Please sign in to comment.