Update preview endpoint to be prefixed with /app to not require an updated proxy config

This commit is contained in:
Andrew Kingston 2022-09-07 10:40:00 +01:00
parent 4ba16eaf0a
commit 8925cdf83e
5 changed files with 4 additions and 12 deletions

View File

@ -65,10 +65,6 @@ http {
proxy_pass http://{{ address }}:4001; proxy_pass http://{{ address }}:4001;
} }
location /preview {
proxy_pass http://{{ address }}:4001;
}
location /builder { location /builder {
proxy_pass http://{{ address }}:3000; proxy_pass http://{{ address }}:3000;
rewrite ^/builder(.*)$ /builder/$1 break; rewrite ^/builder(.*)$ /builder/$1 break;

View File

@ -88,10 +88,6 @@ http {
proxy_pass http://$apps:4002; proxy_pass http://$apps:4002;
} }
location /preview {
proxy_pass http://$apps:4002;
}
location = / { location = / {
proxy_pass http://$apps:4002; proxy_pass http://$apps:4002;
} }

View File

@ -290,7 +290,7 @@
<iframe <iframe
title="componentPreview" title="componentPreview"
bind:this={iframe} bind:this={iframe}
src="/preview" src="/app/preview"
class:hidden={loading || error} class:hidden={loading || error}
class:tablet={$store.previewDevice === "tablet"} class:tablet={$store.previewDevice === "tablet"}
class:mobile={$store.previewDevice === "mobile"} class:mobile={$store.previewDevice === "mobile"}

View File

@ -56,7 +56,7 @@ router
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
controller.deleteObjects controller.deleteObjects
) )
.get("/preview", authorized(BUILDER), controller.serveBuilderPreview) .get("/app/preview", authorized(BUILDER), controller.serveBuilderPreview)
.get("/:appId/:path*", controller.serveApp) .get("/:appId/:path*", controller.serveApp)
.get("/app/:appUrl/:path*", controller.serveApp) .get("/app/:appUrl/:path*", controller.serveApp)
.post( .post(

View File

@ -150,14 +150,14 @@ describe("/static", () => {
}) })
}) })
describe("/preview", () => { describe("/app/preview", () => {
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks() jest.clearAllMocks()
}) })
it("should serve the builder preview", async () => { it("should serve the builder preview", async () => {
const headers = config.defaultHeaders() const headers = config.defaultHeaders()
const res = await request.get(`/preview`).set(headers).expect(200) const res = await request.get(`/app/preview`).set(headers).expect(200)
expect(res.body.appId).toBe(config.appId) expect(res.body.appId).toBe(config.appId)
expect(res.body.builderPreview).toBe(true) expect(res.body.builderPreview).toBe(true)