I am not an expert on this subject.
But I guess you can follow procedure similar to the PLS regression.
I mean:
Find the first CCA components of X (feature variables) and Y (target variables). Name them as t and u, respectively (although u is not used afterwards). Store the weight w and the loading vector p.
Deflate X so that it has no correlation with t : X -> X-(1/t^T t)tt^T X
Perform linear regression of Y on t. Take the residual (estimation error) of this linear regression as the new, deflated Y : Y -> Y-(1/t^T t)tt^T Y
Take the deflated X and Y as new X and Y, and go back to 1.
Iterate the steps from 1 to 4 as many as you like. Then you get the final linear estimation : Y_{estimate} = X_{test}R where R = W(P^TW)^{-1}. Here, W=(w_1, w_2,...) and P=(p_1, p_2, ...) where w_k and p_k are the k-th weight and loading vector.
Both X and Y are assumed to be centered (their sample means are zero). In practice, you should add or subtract the means of the train data when predicting.
Note that the "k-th CCA component" above is generally not the same as that obtained by the usual CCA decomposition, where you obtain CCA components theoretically at once by solving only one eigenvalue equation without performing any deflation. (I am not familiar enough on this point.)
For your information, the procedure of the PLS regression will be most concisely understandable by the Scikit-learn implementation:
https://github.com/scikit-learn/scikit-learn/blob/7e85a6d1f/sklearn/cross_decomposition/_pls.py#L137