before you submit your data on the other page, you can add additional form data
const handleSubmit(event: React.FormEvent<HTMLFormElement>){
const formData = new FormData(event.currentTarget);
formData.append("location", "this pages url location");
submit(formData, { action="/where/to/submit" });
}
Now that you have this location value present in your action function.
You can Flash errors using a session cookie. https://remix.run/docs/en/v1/api/remix#createcookiesessionstorage
To handle the errors you can
sessionIdSession.flash("someErrorName", "We've sent you an error.");
throw redirect("/somelocation", {
headers: {
"Set-Cookie": await sessionStorage.commitSession(sessionIdSession),
},
});
Now in your loader you can read the session data, and get your errors on any page, even though you submit to a different route