This commit is contained in:
dsyoon
2026-01-04 12:33:00 +09:00
parent 2827880351
commit 4398f2929b
2 changed files with 22 additions and 6 deletions

View File

@@ -19,11 +19,11 @@ export function AuthProvider({ children }) {
let res;
try {
res = await fetch(`${API_BASE_URL}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ email, password }),
});
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ email, password }),
});
} catch (e) {
throw new Error('네트워크 오류로 로그인에 실패했습니다. (서버 접속 불가)');
}

View File

@@ -17,6 +17,14 @@ function normalizeExternalUrl(raw) {
return s; // leave as-is (could be relative path on same origin)
}
function extractFirstHttpUrl(text) {
if (!text) return '';
const s = String(text);
// Capture first http/https URL until whitespace or common terminators.
const m = s.match(/https?:\/\/[^\s"'<>]+/i);
return m ? m[0] : '';
}
export default function AiNewsPage({ onNavigate }) {
const { user } = useAuth();
const [news, setNews] = useState([]);
@@ -109,7 +117,7 @@ export default function AiNewsPage({ onNavigate }) {
if (nextOffset === null || nextOffset === offset) {
setNewsHasMore(false);
} else {
setNewsOffset(nextOffset);
setNewsOffset(nextOffset);
}
return nextOffset;
} catch (e) {
@@ -233,6 +241,14 @@ export default function AiNewsPage({ onNavigate }) {
onChange={(e) => setNewsUrl(e.target.value)}
placeholder="뉴스 URL을 입력하세요"
style={{ width: 'calc(100% - 25px)', marginBottom: 8, padding: '10px 12px', borderRadius: 8, border: '1px solid #ffd6c2' }}
onPaste={(e) => {
const pasted = e.clipboardData?.getData('text') || '';
const url = extractFirstHttpUrl(pasted);
if (url) {
e.preventDefault();
setNewsUrl(url);
}
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();