Separate forms app#1960
Conversation
latin-panda
left a comment
There was a problem hiding this comment.
It's exciting to see the standalone app coming through! I left a couple of minor comments below.
| try_files $uri @blank.html; | ||
| } | ||
|
|
||
| location ~ ^/f/.+|/projects/\d+/forms/[^/]+(?:/draft)?(?:/preview|/submissions/new(?:/offline)?/?|/submissions/[^/]+/edit)/?$ { |
There was a problem hiding this comment.
It's tricky to instantly figure out which URLs this regex covers. It's a shame that map variables aren't supported here.
What do you think about separating into two groups, short URLs and project URLs?
Adding examples of URLs is a big help for anyone reading this.
# Forms app - short form URLs (/f/{formId}...)
# Examples:
# - GET /f/abc123
# - GET /f/abc123/preview
# - GET /f/abc123/submissions/new?single=true
# - GET /f/abc123/submissions/{id}/edit
location ~ ^/f/[^/]+(?:/.*)? {
root /usr/share/nginx/html;
try_files $uri $uri/ /apps/forms/index.html;
add_header Content-Security-Policy-Report-Only "$central_frontend_csp" always;
include /usr/share/odk/nginx/common-headers.conf;
}
# Forms app - project forms URLs (/projects/{id}/forms/...)
# Examples:
# - GET /projects/123/forms/abc
# - GET /projects/123/forms/abc/draft
# - GET /projects/123/forms/abc/preview
# - GET /projects/123/forms/abc/submissions/new
# - GET /projects/123/forms/abc/submissions/{id}/edit
location ~ ^/projects/\d+/forms/[^/]+(?:/(?:draft|preview|submissions)(?:/.*)?)? {
root /usr/share/nginx/html;
try_files $uri $uri/ /apps/forms/index.html;
add_header Content-Security-Policy-Report-Only "$central_frontend_csp" always;
include /usr/share/odk/nginx/common-headers.conf;
}I think splitting is better for readability. Alternatively, keep one block:
# Forms app - handles both short form URLs and project form URLs
# Matches:
# - /f/{formId} (short form URL)
# - /f/{formId}/preview (form preview)
# - /f/{formId}/submissions/new (new submission)
# - /f/{formId}/submissions/new/offline (offline new submission)
# - /f/{formId}/submissions/{submissionId}/edit (edit submission)
# - /projects/{projectId}/forms/{formId} (project form)
# - /projects/{projectId}/forms/{formId}/draft (draft version)
# - /projects/{projectId}/forms/{formId}/preview (draft preview)
# - /projects/{projectId}/forms/{formId}/submissions/* (submissions)
location ~ ^(/f/.+|/projects/\d+/forms/[^/]+(?:/draft)?(?:/preview|/submissions/new(?:/offline)?/?|/submissions/[^/]+/edit)/?)$ {
root /usr/share/nginx/html;
try_files $uri $uri/ /apps/forms/index.html;
add_header Content-Security-Policy-Report-Only "$central_frontend_csp" always;
include /usr/share/odk/nginx/common-headers.conf;
}In the last example, I'm grouping the regex, but still hard to read.
There was a problem hiding this comment.
I kept the regex combined, to reduce the chances of the directives getting updated independently.
Good point on the comments which are definitely helpful. Done.
| add_header Content-Security-Policy-Report-Only "$central_frontend_csp" always; | ||
|
|
||
| include /usr/share/odk/nginx/common-headers.conf; | ||
| } |
There was a problem hiding this comment.
Are there currently automated tests to verify the URLs? Just making sure no hidden URL is being dynamically built and missed by us.
There was a problem hiding this comment.
The frontend e2e tests do a reasonable job of covering, particularly the old /f urls. The frontend build checks out this config to run the e2e tests so it is being covered from there.
This is the nginx change needed to run in prod (and get the e2e tests running) for the associated central-frontend patch.
getodk/web-forms#535
What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Before submitting this PR, please make sure you have:
nextbranch OR only changed documentation/infrastructure (masteris stable and used in production)