Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sitemap proxied from nextjs app #183

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions .kontinuous/env/dev/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
api:
cmd: true
args:
- sh
- -c
- "yarn strapi import --force -f seed-data.tar.gz && yarn start"
~preDeploy.cleaner:
match:
kind: Deployment
Expand All @@ -18,13 +13,37 @@ api:
# so public cannot be a volume, it must be its parent
# see https://github.com/strapi/strapi/issues/17809
initContainers:
- name: move-public-to-volume
- name: import-and-prepare
image:
"{{ .Values.global.registry }}/{{ .Values.global.projectName }}/{{
.Values.global.imageRepository }}/api:{{ .Values.global.imageTag }}"
command: ["/bin/sh", "-c"]
args:
- cp -r public/. /mnt/public;
- |
yarn strapi import --force -f seed-data.tar.gz && \
cp -r public/. /mnt/public
volumeMounts:
- name: public
mountPath: /mnt/public
envFrom:
- secretRef:
name: pg-app
- secretRef:
name: api
env:
- name: DATABASE_HOST
value: "$(PGHOST)"
- name: DATABASE_PORT
value: "$(PGPORT)"
- name: DATABASE_NAME
value: "$(PGDATABASE)"
- name: DATABASE_USERNAME
value: "$(PGUSER)"
- name: DATABASE_PASSWORD
value: "$(PGPASSWORD)"
- name: HOST
value: "0.0.0.0"
- name: PORT
value: "1337"
- name: DATABASE_CLIENT
value: postgres
2 changes: 0 additions & 2 deletions .kontinuous/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ api:
~needs: ["build-api", "pg"]
imagePackage: api
probesPath: /_health
startupProbe:
initialDelaySeconds: 300
containerPort: "1337"
envFrom:
- secretRef:
Expand Down
28 changes: 28 additions & 0 deletions next-app/app/sitemap.xml/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// sitemap/index.xml
// https://api-ozensemble-site.fabrique.social.gouv.fr/api/sitemap/index.xml
export const dynamic = "force-dynamic" // defaults to auto

export async function GET() {
const sitemap = await fetch(
"https://api-ozensemble-site.fabrique.social.gouv.fr/api/sitemap/index.xml"
).then((res) => res.text())

if (!sitemap) {
return new Response("It exists but its fucked up", {
headers: {
"Content-Type": "text/xml",
},
})
}
return new Response(
sitemap.replace(
`<?xml-stylesheet type="text/xsl" href="xsl/sitemap.xsl"?>`,
``
),
{
headers: {
"Content-Type": "text/xml",
},
}
)
}
2 changes: 1 addition & 1 deletion next-app/public/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ User-agent: *
Allow: /public/ # Allow crawling of pages in the /public/ directory
Allow: /images/ # Allow crawling of images
Disallow: /fb-redirection/
Sitemap: https://api-ozensemble-site.fabrique.social.gouv.fr/api/sitemap/index.xml
Sitemap: https://ozensemble-site.fabrique.social.gouv.fr/sitemap.xml
Loading