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

Prefix path router #3592

Open
wants to merge 116 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
3e22a58
added prefixPath for site
giuliaghisini May 12, 2022
a6cf32e
handle prefixPath in api requests
giuliaghisini May 13, 2022
a523fa7
added Image component to handle prefixPath in images
giuliaghisini May 13, 2022
30d2638
fixed prefix path in page head
giuliaghisini May 13, 2022
0be7e30
handle prefixPath in chunkExtractor
giuliaghisini May 13, 2022
ab146ac
fixed publickPath in ChunkExtractor with prefixPath
giuliaghisini May 13, 2022
cb21196
added namespace to chunkextractor
giuliaghisini May 13, 2022
4c35003
fix static paths in razzle
cekk May 13, 2022
67452b7
handle static resources with prefix path
giuliaghisini May 16, 2022
c485e5f
fix: fix empty values
giuliaghisini May 20, 2022
9505e56
fix: fix flattenHTMLtoAppUrl to handle prefixPath
giuliaghisini May 27, 2022
f2f908e
feat: added addPrefixPath util to handle static resources
giuliaghisini Aug 11, 2022
c284ec5
Update APIResourceWithAuth.js
giuliaghisini Aug 30, 2022
97f3f9c
Update Api.js
giuliaghisini Aug 30, 2022
f37a938
fix: fix linter
giuliaghisini Aug 31, 2022
76f0f33
fix: image and file views
pnicolli Sep 2, 2022
ed28182
fix: image and file views
pnicolli Sep 2, 2022
57537bb
fix: back to using simple <a> tag for ImageView
pnicolli Sep 5, 2022
4a6f184
readded tests inadvertently removed
mamico Sep 10, 2022
dfdd13f
fix tests
mamico Sep 11, 2022
e38bccc
fix tests
mamico Sep 11, 2022
cf7d2ae
fix(warning): StyleMenu dropdown item to use data-attr instead of cus…
nileshgulia1 Nov 9, 2022
3be3238
add prefix-path express-middleware
nileshgulia1 Dec 8, 2022
1ceb872
Put prefixPath in config.devServer.devMiddleware.publicPath
wesleybl Jul 4, 2023
d6f8bab
Add cypress to prefix path router (#3719)
sneridagh Jul 12, 2023
7f435b0
Avoid /my-prefix from being redirected to /my-prefix/
wesleybl Jul 12, 2023
aa7ef2b
Merge branch 'master' into prefix_path_router
nileshgulia1 Jul 18, 2023
30a9799
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 17, 2023
63c7858
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 17, 2023
035bc59
Merge branch 'main' into prefix_path_router
claudiaifrim Nov 17, 2023
392bdfd
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 20, 2023
9af9eb8
tests: update snapshots
nileshgulia1 Nov 20, 2023
e201fc3
fix(tests): remove duplicate testing-library import
nileshgulia1 Nov 20, 2023
3089740
tests: fix assertion on img src
nileshgulia1 Nov 20, 2023
7037193
tests: more fixes
nileshgulia1 Nov 20, 2023
1b4baa6
tests: intercept prefix calls
nileshgulia1 Nov 21, 2023
cc13733
tests: bring back multilingual cypress suite
nileshgulia1 Nov 22, 2023
88d8ed4
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 22, 2023
bbf84cb
fix: remove unneeded code
nileshgulia1 Nov 25, 2023
3ad97df
fix: use asyncPropExtenders for /controlpanel route when prefixed
nileshgulia1 Nov 26, 2023
6b3e876
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 27, 2023
b964d97
fix: test-setup config
nileshgulia1 Nov 27, 2023
b8d8413
fix(test): controlpanels.test.jsx
nileshgulia1 Nov 27, 2023
40e5379
Merge branch 'main' into prefix_path_router
nileshgulia1 Nov 28, 2023
db1fe08
refactor: use `addPrefixPath` helper in Image src
nileshgulia1 Nov 28, 2023
ef6216a
refactor: prettify components
nileshgulia1 Nov 28, 2023
21162d3
Merge branch 'main' into prefix_path_router
nileshgulia1 Dec 18, 2023
14de201
fix(CI): use pnpm
nileshgulia1 Dec 18, 2023
e8b3859
fix(CI): run cypress in packages/volto, update changelog
nileshgulia1 Dec 19, 2023
04dc8aa
fix: update prefix-tests
nileshgulia1 Dec 19, 2023
ecd601d
refactor: shift acceptance tests in packages/volto MAKEFILE
nileshgulia1 Dec 19, 2023
0b5bff7
ref:point to internal makefile tests
nileshgulia1 Dec 19, 2023
260cfcd
update acceptance.yml
nileshgulia1 Dec 19, 2023
f3dd2b5
fix: force yarn to vanish completely
nileshgulia1 Dec 19, 2023
1c676ff
update makefile
nileshgulia1 Dec 19, 2023
cfb5a73
fix: move changelog to correct folder
nileshgulia1 Dec 19, 2023
000f503
delete dangling one
nileshgulia1 Dec 19, 2023
76008a6
chore: amend volto-slate changelog
nileshgulia1 Dec 19, 2023
39c1e4a
Merge branch 'main' into prefix_path_router
claudiaifrim Jan 19, 2024
22749f9
Merge branch 'main' into prefix_path_router
claudiaifrim Jan 25, 2024
1b78ad5
Merge branch 'main' into prefix_path_router
nileshgulia1 Jan 29, 2024
fc56c8e
feat: add multilingual prefixed tests
nileshgulia1 Jan 29, 2024
73a3dab
Merge branch 'main' into prefix_path_router
nileshgulia1 Jan 31, 2024
ca6004e
Merge branch 'main' into prefix_path_router
nileshgulia1 Feb 12, 2024
3f3e81f
fix workflow multilingualprefix
nileshgulia1 Feb 12, 2024
ea9c14b
Merge branch 'main' into prefix_path_router
nileshgulia1 Feb 13, 2024
caae9ab
Merge branch 'main' into prefix_path_router
nileshgulia1 Feb 14, 2024
a06a91c
Merge branch 'main' into prefix_path_router
claudiaifrim Feb 22, 2024
735090c
Merge branch 'main' into prefix_path_router
wesleybl Feb 27, 2024
aa0c72b
Merge remote-tracking branch 'origin/main' into prefix_path_router
wesleybl Mar 6, 2024
3938b21
Acceptance tests of prefixed site in Node 20.x
wesleybl Mar 6, 2024
b07f431
Update github actions versions
wesleybl Mar 6, 2024
3a10d4a
Force install Cypress
wesleybl Mar 6, 2024
562e01e
Restore condition to install Cypress
wesleybl Mar 6, 2024
c50341b
Fix cache key
wesleybl Mar 7, 2024
61d96d2
Use addPrefixPath in Logo component
wesleybl Mar 7, 2024
c793816
Use addPrefixPath in image scales
wesleybl Mar 8, 2024
48554df
Merge branch 'main' into prefix_path_router
wesleybl Mar 8, 2024
294a090
Merge branch 'main' into prefix_path_router
nileshgulia1 Mar 11, 2024
ad3a147
Merge branch 'main' into prefix_path_router
wesleybl Mar 13, 2024
8d8edf3
Merge branch 'main' into prefix_path_router
wesleybl Mar 14, 2024
9a6b25f
Remove use asyncPropExtenders for /controlpanel route when prefixed
wesleybl Mar 14, 2024
149c899
Add routes with prefix path
wesleybl Mar 15, 2024
e32637b
Test core basic with prefixed site
wesleybl Mar 14, 2024
5eddf39
Test core content with prefixed site
wesleybl Mar 15, 2024
8cf3b05
Test core control panels with prefixed site
wesleybl Mar 15, 2024
5ce2e94
Test core blocks with prefixed site
wesleybl Mar 15, 2024
a59a704
Add prefix to the URL of Image Gallery images
wesleybl Mar 18, 2024
2944946
Pass the prefixPath environment variable to the test-acceptance-prefixed
wesleybl Mar 18, 2024
235e4c5
Test core blocks listing with prefixed site
wesleybl Mar 15, 2024
38e428c
Test core volto slate with prefixed site
wesleybl Mar 18, 2024
1e2620e
Merge branch 'main' into prefix_path_router
wesleybl Mar 18, 2024
f3a51a4
Merge branch 'main' into prefix_path_router
nileshgulia1 May 13, 2024
433ad1c
fix: use prefix in flattenToAppUrl, keep assets intact in dev
nileshgulia1 May 16, 2024
dd553b8
remove: addprefixPath helper
nileshgulia1 May 16, 2024
d66b0ac
fix: client and server warnings
nileshgulia1 May 16, 2024
a38dda0
Merge branch 'main' into prefix_path_router
nileshgulia1 May 16, 2024
0afb5c7
Merge branch 'main' into prefix_path_router
sneridagh Jun 7, 2024
b220146
Merge remote-tracking branch 'origin/main' into prefix_path_router
wesleybl Jul 8, 2024
699dfb1
Update pnpm-lock.yaml with main
wesleybl Jul 8, 2024
e8b69cf
Rename Makefile targets
wesleybl Jul 10, 2024
d1263ee
Merge branch 'main' into prefix_path_router
nileshgulia1 Jul 11, 2024
c2ae5a4
Does not add prefix in the flattenToAppURL function
wesleybl Jul 12, 2024
223cf17
Create function addPrefixPath
wesleybl Jul 15, 2024
0d357e1
Uses addPrefixPath where it is not possible to use the Link and
wesleybl Jul 15, 2024
453bdbc
Merge branch 'main' into prefix_path_router
wesleybl Jul 24, 2024
7efbd7f
Merge branch 'main' into prefix_path_router
wesleybl Jul 26, 2024
9e4712e
Merge branch 'main' into prefix_path_router
wesleybl Jul 30, 2024
06f3e1f
Allows use of RAZZLE PREFIX PATH variable in development mode
wesleybl Jul 30, 2024
e6ea8aa
Merge branch 'main' into prefix_path_router
wesleybl Oct 29, 2024
2b59a49
Uses actions/upload-artifact v4
wesleybl Oct 29, 2024
3856b7c
Updates configuration of prefixed acceptance tests
wesleybl Oct 29, 2024
5e90e60
Use `docker compose` in deployment-prefixed-acceptance-web-server-start
wesleybl Oct 29, 2024
e8889fe
Fixes prefixed workingcopy tests
wesleybl Oct 30, 2024
ccc0b0e
Allows use of RAZZLE_PREFIX_PATH variable in development mode
wesleybl Nov 4, 2024
01148eb
Does not avoid redirect /prefix -> prefix/
wesleybl Nov 4, 2024
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
170 changes: 170 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,3 +1226,173 @@ jobs:
with:
name: cypress-videos
path: packages/volto/cypress/videos

prefix:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: Prefixed site
runs-on: ubuntu-latest
timeout-minutes: 35
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

# pnpm install
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Cache Cypress Binary
id: cache-cypress-binary
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: binary-${{ matrix.node-version }}-${{ hashFiles('pnpm-lock.yaml') }}

- run: pnpm i

- name: Install Cypress if not in cache
if: steps.cache-cypress-binary.outputs.cache-hit != 'true'
working-directory: packages/volto
run: make cypress-install

- name: Cypress acceptance tests
uses: cypress-io/github-action@v6
env:
BABEL_ENV: production
CYPRESS_RETRIES: 2
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
install: false
working-directory: packages/volto
browser: chrome
spec: cypress/tests/minimal/**/*.js
config: baseUrl=http://localhost/foo
env: prefixPath=/foo
start: |
make start-test-acceptance-server
make start-test-acceptance-frontend-prefixed
make start-test-acceptance-webserver-prefixed
wait-on: 'npx wait-on --httpTimeout 20000 http-get://127.0.0.1:55001/plone http://127.0.0.1:3000/foo http://localhost/foo'

# Upload Cypress screenshots
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: packages/volto/cypress/screenshots
# Upload Cypress videos
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-videos
path: packages/volto/cypress/videos

multilingualprefix:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: Multilingual in Prefixed site
runs-on: ubuntu-latest
timeout-minutes: 35
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

# pnpm install
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Cache Cypress Binary
id: cache-cypress-binary
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: binary-${{ matrix.node-version }}-${{ hashFiles('pnpm-lock.yaml') }}

- run: pnpm i

- name: Install Cypress if not in cache
if: steps.cache-cypress-binary.outputs.cache-hit != 'true'
working-directory: packages/volto
run: make cypress-install

- name: Cypress acceptance tests
uses: cypress-io/github-action@v6
env:
BABEL_ENV: production
CYPRESS_RETRIES: 2
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
install: false
working-directory: packages/volto
browser: chrome
spec: cypress/tests/multilingual/**/*.js
config: baseUrl=http://localhost/foo
env: prefixPath=/foo
start: |
make start-test-acceptance-server-seamless-multilingual
make start-test-acceptance-frontend-prefixed-multilingual
make start-test-acceptance-webserver-prefixed
wait-on: 'npx wait-on --httpTimeout 20000 http-get://127.0.0.1:55001/plone http://127.0.0.1:3000/foo http://localhost/foo'

# Upload Cypress screenshots
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: packages/volto/cypress/screenshots
# Upload Cypress videos
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-videos
path: packages/volto/cypress/videos
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,24 @@ test-acceptance-multilingual-headless: ## Start Multilingual Cypress Acceptance
full-test-acceptance-multilingual: ## Runs Multilingual Full Acceptance Testing in headless mode
$(MAKE) -C "./packages/volto/" full-test-acceptance-multilingual

######### Prefixed Core Acceptance tests

.PHONY: start-test-acceptance-frontend-prefixed
start-test-acceptance-frontend-prefixed: ## Start the prefixed Core Acceptance Frontend Fixture
$(MAKE) -C "./packages/volto/" start-test-acceptance-frontend-prefixed

.PHONY: full-test-acceptance-prefixed
full-test-acceptance-prefixed: ## Runs prefixed Core Full Acceptance Testing in headless mode
$(MAKE) -C "./packages/volto/" full-test-acceptance-prefixed

.PHONY: test-acceptance-prefixed
test-acceptance-prefixed: ## Start Prefixed Cypress Acceptance Tests
$(MAKE) -C "./packages/volto/" test-acceptance-prefixed

.PHONY: start-test-acceptance-webserver-prefixed
start-test-acceptance-webserver-prefixed: ## Start the prefixed webserver
$(MAKE) -C "./packages/volto/" start-test-acceptance-webserver-prefixed

######### Seamless Multilingual Acceptance tests

.PHONY: start-test-acceptance-server-seamless-multilingual test-acceptance-server-seamless-multilingual
Expand Down
1 change: 1 addition & 0 deletions docs/source/deploying/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ seamless-mode
apache
sentry
performance
prefixed-root
```
58 changes: 58 additions & 0 deletions docs/source/deploying/prefixed-root.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this page needs to have better narrative structure, such as the following:

  • Introduction that states the essential and basic requirements for a deployment, regardless of root or non-root. This might already exist somewhere in the Deploying section. Side note: that entire section needs to be cleaned up, and I think the index page should have this introduction as its introduction, so we can easily refer to it. We can also use an include to avoid copy-paste drift.
  • Clarify what these requirements do and why they are necessary.
  • Then add to the basic requirements those things that are required for a non-root deployment.
  • Again, clarify what these requirements do and why they are necessary.
  • Finally show examples of implementation details, whether it is Apache, nginx, or whatever. It is OK to have multiple examples. In fact I would use Sphinx Design with a tabbed code example interface.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
myst:
html_meta:
"description": "Prefixed (non-root) deployment for Volto"
"property=og:description": "Prefixed (non-root) deployment for Volto"
"property=og:title": "Prefixed (non-root) deployment"
"keywords": "Volto, deployment"
---

# Prefixed (non-root) deployment

If you're integrating a Volto website within another existing website, you may need to run Volto on a virtual path inside that website instead of the root path.

The first step is to set an environment variable `RAZZLE_PREFIX_PATH` to the prefixed path of your Volto.
For example, if you want Volto's root to be hosted at `http://example.com/my-prefix`, you need to start Volto with:

```shell
RAZZLE_PREFIX_PATH=/my-prefix yarn start
```

If you need to debug and understand how the requests are rewritten by the Volto SSR, you can add the following environment variables to the Volto start line:


```shell
DEBUG_HPM=true DEBUG=superagent RAZZLE_PREFIX_PATH=/my-prefix yarn start
```

The prefix location will be used regardless of how you start Volto, whether in development or production mode.
When developing, though, if your backend is something other then `http://localhost:8080`, you'll need to provide your own solution for how to handle things.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in development I don't have to set it up and act as I'm in the root then?


For a production setup, when hosting Volto behind a proxy HTTP server, you can configure your rewrite rules to something like the following, in this case for Apache.

```apache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recommended deployment setup is using Docker. I know that the documentation about this is in a sorry state, but we cannot add more confusion about this by dropping an Apache config here. I don't have a good solution for this one :(

In the upcoming sprints we should work on documenting properly the deployment story.

/cc @ericof @davisagli @stevepiercy @fredvd

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sneridagh would it be an idea to use an example with nginx, since docker uses nginx?

RewriteRule ^/level-1/\+\+api\+\+(.*) http://plone:8080/VirtualHostBase/http/example.com:80/Plone/VirtualHostRoot/_vh_level-1$1 [P,L]
RewriteRule ^/level-1(.*) http://volto:3000/level-1$1 [P,L]
```

In case you have a deeper prefix path (for example, `/level1/level2`), you can do the following.
Notice the multiple `_vh_` segments in the rewrite rule.

```apache
RewriteRule ^/level-1/level-2/\+\+api\+\+(.*) http://plone:8080/VirtualHostBase/http/example.com:80/Plone/VirtualHostRoot/_vh_level-1/_vh_level-2$1 [P,L]
RewriteRule ^/level-1/level-2(.*) http://volto:3000/level-1/level-2$1 [P,L]
```

And start Volto with the following.

```shell
RAZZLE_PREFIX_PATH=/level1/level2 RAZZLE_API_PATH=http://example.com/level1/level2 yarn start
```

Note, as you'll be integrating Volto with an existing website, you need to configure `config.settings.externalRoutes` so that the router knows which routes it should consider internal.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more elaboration and reasoning why this is necessary.


Finally, because `RAZZLE_PREFIX_PATH` is also used to configure the location of the static resources in webpack, when you build the static resources bundle, you must use a command such as the following.

```shell
RAZZLE_PREFIX_PATH=/level1/level2 yarn build
```
1 change: 1 addition & 0 deletions packages/volto-slate/news/4290.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
added support for prefixPath. @giuliaghisini @cekk @pnicolli @mamico @nileshgulia1 @wesleybl
3 changes: 2 additions & 1 deletion packages/volto-slate/src/editor/plugins/Image/render.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { useSelected, useFocused } from 'slate-react';
import { Image } from '@plone/volto/components';

export const ImageElement = (props) => {
const { attributes, children, element } = props;
Expand All @@ -16,7 +17,7 @@ export const ImageElement = (props) => {
return (
<span {...attributes} style={{ display: 'inline-block' }}>
{children}
<img alt="" src={element.url} style={style} />
<Image alt="" src={element.url} style={style} />
</span>
);
};
24 changes: 24 additions & 0 deletions packages/volto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,30 @@ test-acceptance-workingcopy-headless: ## Start WorkingCopy Cypress Acceptance Te
full-test-acceptance-workingcopy: ## Runs WorkingCopy Full Acceptance Testing in headless mode
$(NODEBIN)/start-test "make start-test-acceptance-server-workingcopy" http-get://127.0.0.1:55001/plone "make start-test-acceptance-frontend-workingcopy" http://127.0.0.1:3000 "make test-acceptance-workingcopy-headless"

######### Prefixed Core Acceptance tests

.PHONY: start-test-acceptance-frontend-prefixed
start-test-acceptance-frontend-prefixed: build-deps ## Start the prefixed Core Acceptance Frontend Fixture
RAZZLE_PREFIX_PATH=/foo RAZZLE_API_PATH=http://localhost/foo pnpm build && pnpm start:prod

.PHONY: full-test-acceptance-prefixed
full-test-acceptance-prefixed: ## Runs prefixed Core Full Acceptance Testing in headless mode
$(NODEBIN)/start-test "make start-test-acceptance-server" http-get://localhost:55001/plone "make start-test-acceptance-frontend-prefixed" http://localhost:3000 "make test-acceptance-headless"

.PHONY: test-acceptance-prefixed
test-acceptance-prefixed: ## Start Prefixed Cypress Acceptance Tests
NODE_ENV=production CYPRESS_API=plone $(NODEBIN)/cypress open --config baseUrl='http://localhost/foo'

.PHONY: start-test-acceptance-webserver-prefixed
start-test-acceptance-webserver-prefixed: ## Start the prefixed webserver
cd cypress/docker && docker-compose -f prefixed.yml up

######### Prefixed Multilingual Acceptance tests

.PHONY: start-test-acceptance-frontend-prefixed-multilingual
start-test-acceptance-frontend-prefixed-multilingual: build-deps ## Start the prefixed Core Acceptance Frontend Fixture
ADDONS=@plone/volto-coresandbox:multilingualFixture RAZZLE_PREFIX_PATH=/foo RAZZLE_API_PATH=http://localhost/foo pnpm build && pnpm start:prod

######### Guillotina Acceptance tests

.PHONY: start-test-acceptance-server-guillotina
Expand Down
27 changes: 27 additions & 0 deletions packages/volto/cypress/docker/prefixed-rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
http:
routers:
frontend:
rule: "Host(`localhost`) && PathPrefix(`/foo`)"
service: frontend
backend:
rule: "Host(`localhost`) && PathPrefix(`/foo/++api++`)"
service: backend
middlewares:
- backend

middlewares:
backend:
replacePathRegex:
regex: "^/foo/\\+\\+api\\+\\+($|/.*)"
replacement: "/VirtualHostBase/http/localhost/plone/++api++/VirtualHostRoot/_vh_foo$1"

services:
frontend:
loadBalancer:
servers:
- url: "http://host.docker.internal:3000"
backend:
loadBalancer:
servers:
- url: "http://host.docker.internal:55001"

24 changes: 24 additions & 0 deletions packages/volto/cypress/docker/prefixed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.7"

services:

proxy:
image: traefik:v2.8
command:
- "--api.insecure=true"
- "--providers.docker=true"
# - "--providers.docker.exposedbydefault=false"
- "--providers.file=true"
- "--providers.file.filename=/etc/traefik/rules.yml"
- "--entrypoints.web.address=:80"
- "--api.insecure=true"
# - "--accesslog=true"
# - "--log.level=DEBUG"
ports:
- 80:80
- "8888:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./prefixed-rules.yml:/etc/traefik/rules.yml
extra_hosts:
- host.docker.internal:host-gateway
Loading
Loading