Let us consider here the continuous elements of $L^2$.
It is often stated that the family $e_k(x) = e^{-2 \pi i k x}$ is an orthonormal basis of $L^2[0, 1]$, in that a function can be written as $$ f(x) = \sum_{k \in \mathbb{Z}} c_k e_k(x), $$ for an appropriate complex sequence $c_k$.
However, my confusion is that, since $e_k(0) = e_k(1) =1$ for all $k$, it would seem that this representation forces $$ f(0) = f(1). $$
Is there a calculation mistake here? Or is it an issue with point evaluation in $L^2[0, 1]$? If it is the latter, is there a way to change the basis $e_k$ such that a valid point-wise representation holds everywhere (say for continuous representatives/elements of $L^2$)?
For instance, what about the function $f(x) = x$?
A more rigorous version of my second question goes as follows. Is there an orthonormal basis $\{e_k\}$ for $L^2[0, 1]$ such that for continuous elements of $C[0, 1]$ there exists a sequence $c_k$ where the the partial sums $f_N = \sum_{|k|\leq N} c_k e_k$ $$ \sup_{x \in [0, 1]} |f(x) - f_N(x)| \to 0, \quad \mbox{as}~N \to \infty? $$
Your confusion is entirely reasonable! Yes, it should come as a shock when one first learns that "convergence" of Fourier series can have different, inequivalent, senses. From a reasonable beginner's viewpoint, of_course "convergence" means "pointwise". Duh. Oop, but Fourier series don't reliably do that. As some sort of consolation-prize, we do have $L^2$ convergence... which is simply not-at-all equivalent to pointwise convergence. Truly, this stunned me when I first understood the fact. Wow. Oof.
(Ok, yes, there is Carleson's theorem, that an $L^2$ function's Fourier series does converge almost everywhere (to that function...))
Further, yes, there is the mysterious connection between $f(0)$ and $f(1)$, and similarly for derivatives, in whatever sense. Yes, of course, the relevant exponentials have equal values at both ends. The point is that Fourier series most naturally are expansions of periodic functions (of whatever sort), that is, of functions on the circle (pulled-back to make periodic functions on the line... or functions on an interval). That is, the natural object on which Fourier series live is not necessarily an interval, but maybe a circle. Still, yes, there are other boundary-value ODE situations that do specifically refer to intervals...
So, to my mind, the most natural way to understand Fourier series is to think of them as giving functions on the circle. Ok.
For pointwise values? Differentiability? Yes, this can get entangled with the endpoint-value confusion. For example, yes, with the function that's $x$ on $[0,2\pi]$ (or similar), the endpoint values don't match. Not only cannot the Fourier series "converge to both values" at the two endpoints, but, in addition, that very issue makes the whole Fourier series converge much more delicately on the whole interval!!! This is even more mysterious... :)
Of course, there is much more that can be said about convergence of Fourier series... :)