To get rid of the extra term in the QED Lagrangian we need to redefine the electromagnetic four-vector:
$A^{\mu} \rightarrow A^{\mu} - \frac{1}{c} \partial_{\mu} a(x)$ where $a(x)$ is the function that defines the local U(1) symmetry, i.e. sending $\psi(x) \rightarrow e^{ia(x)}\psi(x)$ leaves the QED Lagrangian invariant if we redefine the field as stated above.
To still satisfy the Lorenz gauge ($\partial \cdot A = 0$) we thus need to impose $\partial^2 a(x) = 0$.
In the textbook I'm following the choice for the function a is: $a(x) = c e^{-iqx}$ where q and x are four-vectors and the multiplication means Minkowski scalar product.
I don't see how $\partial^2 \cdot c e^{iqx} = 0$, unless we impose a further condition on $q$, i.e. $q^2$ = 0. That condition would sort of make sense, since the e.m.-field corresponds to massless photons for which that condition is satisfied. Is that what's happening here?