fix(docs): correct API route prefix — strip /api to match Flask proxy convention
- Flask docs routes changed from /api/docs to /docs (no /api prefix) because hooks.server.ts proxies /api/* by stripping /api, so /api/docs reached Flask as /docs (404). Other routes (lessons, help) also lack /api. - Frontend load functions now fetch /docs and /docs/<slug> (not /api/docs) - Fixes 500 on /docs SSR (proxy ECONNREFUSED / 404 from stripped route)
This commit is contained in:
parent
9c2563a2bf
commit
d243df898a
|
|
@ -3,7 +3,7 @@ import type { DocsIndexEntry } from '$types/docs';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const load: PageLoad = async ({ fetch }) => {
|
export const load: PageLoad = async ({ fetch }) => {
|
||||||
const res = await fetch('/api/docs');
|
const res = await fetch('/docs');
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw error(500, 'Gagal memuat daftar dokumentasi');
|
throw error(500, 'Gagal memuat daftar dokumentasi');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import type { DocContent } from '$types/docs';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const load: PageLoad = async ({ params, fetch }) => {
|
export const load: PageLoad = async ({ params, fetch }) => {
|
||||||
const res = await fetch(`/api/docs/${params.slug}`);
|
const res = await fetch(`/docs/${params.slug}`);
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw error(404, 'Dokumen tidak ditemukan');
|
throw error(404, 'Dokumen tidak ditemukan');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ from services.docs_service import get_docs_index, get_doc_content
|
||||||
docs_bp = Blueprint("docs_api", __name__)
|
docs_bp = Blueprint("docs_api", __name__)
|
||||||
|
|
||||||
|
|
||||||
@docs_bp.route("/api/docs")
|
@docs_bp.route("/docs")
|
||||||
def api_docs_index():
|
def api_docs_index():
|
||||||
"""List all docs files with metadata, sorted by order."""
|
"""List all docs files with metadata, sorted by order."""
|
||||||
docs = get_docs_index()
|
docs = get_docs_index()
|
||||||
return jsonify({"docs": docs})
|
return jsonify({"docs": docs})
|
||||||
|
|
||||||
|
|
||||||
@docs_bp.route("/api/docs/<slug>")
|
@docs_bp.route("/docs/<slug>")
|
||||||
def api_doc_detail(slug):
|
def api_doc_detail(slug):
|
||||||
"""Return rendered HTML + metadata for a single doc by slug."""
|
"""Return rendered HTML + metadata for a single doc by slug."""
|
||||||
data = get_doc_content(slug)
|
data = get_doc_content(slug)
|
||||||
|
|
@ -32,7 +32,7 @@ def api_doc_detail(slug):
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
@docs_bp.route("/api/docs/api-reference")
|
@docs_bp.route("/docs/api-reference")
|
||||||
def api_reference():
|
def api_reference():
|
||||||
"""Generate API reference from route docstrings.
|
"""Generate API reference from route docstrings.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue