-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
base: main
Are you sure you want to change the base?
Prefix path router #3592
Conversation
❌ Deploy Preview for volto failed. Why did it fail? →
|
Passing run #7234 ↗︎
Details:
Review all test suite changes for PR #3592 ↗︎ |
Link view now working, Image view still has issues with the download link which is not working (see this example) |
During the Volto Team meeting we agreed that we would have to put in place a whole round of Cypress tests pointing to a deployment using this. I can imagine that in the future will be quite easy to break the whole feature if one does not have in mind it. I think that could be time consuming, but might not have much difficulty. What do you think? |
@mamico @giuliaghisini could you share the reverse proxy config you have on such deployments? |
We should add some documentation about how to setup such a deployment. |
@sneridagh our deployment config is a bit complicated because there are several urls and frontend names, and it's made in varnish and not in nginx/apache. The conf itself for using this branch is easy. Here is an example for nginx:
|
@cekk One other thing is important to document, the prefix path /foo corresponds to the Plone root, not a /foo subfolder in Plone. |
Yes, /foo points to the root of Plone site |
@cekk To make it work I had to launch Volto with:
I would have expect that given a RAZZLE_PREFIX_PATH, the other would have adjusted automatically (as seamless mode promises). I am doing something wrong? because given a look at the code, it seems it should, right? |
@cekk Forget the question, I'm still asleep. 😅 |
Added tentative tests: #3719 see comments. |
I would like to take this forward. Locally looks good. I will checkout this branch on one of our projects first and see if I find some issues. State of this PR:This PR is based on There is another approach in this PR, which uses a store enhancer middleware to prefix all the router paths(amending history accordingly) and modified What's left are the cypress tests #3719 which should also account for prefix path in the URLs. I will try to have a look into them. I personally like the basename approach and let react-router handle the prefixes. However, we need to think about the non-router links and static assets. What do you think @sneridagh @davisagli @tiberiuichim @pnicolli ? |
@giuliaghisini @nileshgulia1 @sneridagh any chance we have this feature in master? |
I updated the branch and run:
Then I got the error: ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'publicPath'. These properties are valid:
object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }
at validate (/home/user/git/volto/node_modules/webpack-dev-server/node_modules/schema-utils/dist/validate.js:115:11)
at new Server (/home/user/git/volto/node_modules/webpack-dev-server/lib/Server.js:231:5)
at new razzleDevServer (/home/user/git/volto/node_modules/razzle/config/razzleDevServer.js:10:5)
at /home/user/git/volto/node_modules/razzle/scripts/start.js:181:33
at processTicksAndRejections (node:internal/process/task_queues:96:5) I'll take a look at it. |
@wesleybl it's due to the changes in razzle.config.js |
@tiberiuichim I fixed this in: f011df6 |
This function adds a prefix to a URL. This function should be used where it is not possible to use the Link and UniversalLink components
UniversalLink components
@nileshgulia1 @sneridagh Cannot add prefix in So I returned with the I have the time and sponsorship to work with this functionality now. From my point of view, it's working well. Tests are passing now. I need guidance on what I should do to improve this PR. |
@nileshgulia1 so can I go back to reading the |
@wesleybl so the idea is like this, if we remove prefix-path addition in flattenToAppUrl, and since we are using the basename we don't have to prefix manually. All the links with a react-router Regarding the development recipe, I think the website itself shouldn't care about the prefix in dev. The prefix should only be used in production. If you want to test it, you can do |
I think it's worth a try not to depend on addPrefixPath function. I would not force anyone to use it in their new addons or components. |
@nileshgulia1 the problem is precisely when we are developing the prefix functionality and we want to see the website with the prefix. The |
That is the thing, why do we want to develop with prefix differently from a normal case? If you want to develop with prefix, you shouldn't do anything special in development. At least that's what we have discussed in @plone/volto-team meeting. Can't we keep things minimal? So just do RAZZLE_PREFIX_PATH=/preffix yarn build && RAZZLE_PREFIX_PATH=/preffix arn start:prod. In any case I would like to hear more thoughts. -cc @sneridagh @giuliaghisini @cekk |
@nileshgulia1 when I say "developing the prefix functionality", I'm talking about situations like fixing the test of a prefixed CI job. Or making changes like prefixing inside or outside the For "normal development", we can start without the variable, as is normally done today. It would be transparent. |
@nileshgulia1 In order to avoid having an I'll try to make a branch removing basename to see how things behave. |
@nileshgulia1 I'm sorry but I'm going to enable reading of the |
Without using this variable in development mode, you need to compile the code with each file change to see the result.
@nileshgulia1 @sneridagh I'm implementing the removal of
In the end, we would have to change many more files than with the use of |
@wesleybl sorry, I can't follow. Tomorrow I can try to take a full read, but at this time of the year I can't devote any effort to make this happen. What do you mean by removing the basename from the router? This is the full base of the feature and we can't remove it. So I'm quite shocked. We've talked about this feature during today's Volto team meeting.
So I propose to start over in a new PR during a sprint, in a joint effort, and go slowly, step by step, argumenting every change with comments, if needed. There has been so many people working in this PR, that I bet that there are changes in there that nobody knows why they are there. Ferrara happens at the end of September. We can start set the bases in there. The Plone Conf is not that far, and the ones that are interested in the feature will attend there. |
@wesleybl ok, @nileshgulia1 created the PLIP: #4290 I'd love to talk to you as well in person (I already did with Nilesh this morning in the Volto Team Meeting). I'm open for a talk during this week (not on Thursday) Let me know if you can. |
@wesleybl I agree that we should have a basename set, that is the starting point in the PR, it takes care of prefixing for us. We need to identify the parts where the prefix is manually needed. For me, focus is more on trying to avoid affecting the future development of volto. Or if we should really introduce env vars starting with RAZZLE_ now. There are lof of efforts that uses another build system and maybe in future we might shift there. |
@nileshgulia1 basically, we need to manually prefix in the HTML tags In short, if we use the |
@sneridagh I sent you an email. |
I'll be happy to join as well. Just ping me in discord. |
@nileshgulia1 @sneridagh I documented in PLIP situations where it is necessary to manually prefix, when using |
This add scripts to start frontend configured for working copy prefixed
In 7f435b0 I tried to avoid this rendirect but when rendering happens on the server side, it was happening Not Found before the client rendered the page correctly.
Enable to publish Volto site under a prefixPath, for example
www.mymainsite.com/prefixPath