Skip to content

Separate forms app#1960

Draft
garethbowen wants to merge 9 commits into
getodk:nextfrom
garethbowen:separate-forms-app
Draft

Separate forms app#1960
garethbowen wants to merge 9 commits into
getodk:nextfrom
garethbowen:separate-forms-app

Conversation

@garethbowen

@garethbowen garethbowen commented Jun 8, 2026

Copy link
Copy Markdown

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:

  • branched off and targeted the next branch OR only changed documentation/infrastructure (master is stable and used in production)
  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

@latin-panda latin-panda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)/?$ {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there currently automated tests to verify the URLs? Just making sure no hidden URL is being dynamically built and missed by us.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants