The solution of heat or diffusion equations with Dirichlet boundary conditions is given by a Fourier series as $$u(x,t)= \sum_{n=1}^\infty c_n e^{-n^2t\kappa(\pi/L)^2} \cos\left( \frac{n\pi x}{L}\right) \\ c_n=\frac{2}{L} \int_0^L f(x) \cos\left(\frac{n\pi x}{L}\right) \,\mathrm{d}x$$
How is the flux at a given $x$ like $0$ or $L$ calculated?
$$J(x,t)=\kappa\frac{\partial u(x,t)}{\partial t}$$