このコミットが含まれているのは:
+15
-1
@@ -5,7 +5,7 @@ import { request as requestHTTPS } from 'node:https'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { render } from './dist/server/entry-server.js'
|
||||
import { render, renderSitemap } from './dist/server/entry-server.js'
|
||||
|
||||
const root = fileURLToPath (new URL ('./dist/client/', import.meta.url))
|
||||
const template = await readFile (path.join (root, 'index.html'), 'utf8')
|
||||
@@ -61,6 +61,20 @@ const server = createServer (async (request, response) => {
|
||||
{
|
||||
const url = new URL (request.url, origin)
|
||||
const pathname = decodeURIComponent (url.pathname)
|
||||
if (pathname === '/sitemap.xml' || pathname.startsWith ('/sitemap-'))
|
||||
{
|
||||
const result = await renderSitemap (url.pathname, origin, apiBaseURL)
|
||||
response.writeHead (result.status, { 'Content-Type': 'application/xml; charset=utf-8' })
|
||||
response.end (request.method === 'HEAD' ? undefined : result.body)
|
||||
return
|
||||
}
|
||||
if (pathname === '/robots.txt')
|
||||
{
|
||||
response.writeHead (200, { 'Content-Type': 'text/plain; charset=utf-8' })
|
||||
response.end (request.method === 'HEAD'
|
||||
? undefined : `Sitemap: ${new URL ('/sitemap.xml', origin).href}\n`)
|
||||
return
|
||||
}
|
||||
const file = path.resolve (root, '.' + pathname)
|
||||
const allowed = file.startsWith (root)
|
||||
&& !pathname.split ('/').some (segment => segment.startsWith ('.'))
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする