fix: extract pathname from absolute image URLs to avoid container host leaking
All checks were successful
Deploy to Server / deploy (push) Successful in 1m54s
All checks were successful
Deploy to Server / deploy (push) Successful in 1m54s
This commit is contained in:
@@ -17,10 +17,10 @@ const { useBreakpoint } = Grid;
|
|||||||
|
|
||||||
const getImageUrl = (url) => {
|
const getImageUrl = (url) => {
|
||||||
if (!url) return '';
|
if (!url) return '';
|
||||||
if (url.startsWith('http') || url.startsWith('//')) return url;
|
if (url.startsWith('http') || url.startsWith('//')) {
|
||||||
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:8000/api';
|
try { return new URL(url).pathname; } catch { return url; }
|
||||||
const baseUrl = apiUrl.replace(/\/api\/?$/, '');
|
}
|
||||||
return `${baseUrl}${url}`;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CodeBlock = ({ inline, className, children, ...props }) => {
|
const CodeBlock = ({ inline, className, children, ...props }) => {
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ const { Title, Paragraph } = Typography;
|
|||||||
// 获取完整图片 URL
|
// 获取完整图片 URL
|
||||||
const getImageUrl = (url) => {
|
const getImageUrl = (url) => {
|
||||||
if (!url) return '';
|
if (!url) return '';
|
||||||
if (url.startsWith('http') || url.startsWith('//')) return url;
|
if (url.startsWith('http') || url.startsWith('//')) {
|
||||||
return `http://localhost:8876${url}`;
|
try { return new URL(url).pathname; } catch { return url; }
|
||||||
|
}
|
||||||
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user