can t seem to find the backend controller
been trying for 2-3 hour ish but doesn t wanna connect
83 Replies
ā
This post has been reserved for your question.
Hey @Timo! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Can you show the content of the network tab in your browser's devtools?

Can you expand the first entry?
How is the backend deployed?

just a basic springboot backend?

this is the structure if that helps
Can you show the application.properties? Are you running it by running the main class?
spring.application.name=Backend NTR-Website
spring.datasource.url=jdbc:postgresql://localhost:5432/database_NTRConcept
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto = create-drop
server.error.include-message=always
server.port=8080
server.servlet.context-path=/api
spring.config.import=file:./JWT.env[.properties],file:./DataBase.env[.properties]
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.default-encoding=UTF-8
yeah like the login register etc work fine
remove the
server.servlet.context-path=/api
or change the request to /api/api/registration
in the frontend or change the RestController
to /registration
but only one of these changes
like this?

for example
server.servlet.context-path=/api
means that /api
is added at the beginning of all endpoints
you could also just remove that line from the application.propertieswhy not delete from the event controller

\
do whatever you prefer

now i get a 500 error

check the Spring logs
2025-06-07T16:20:51.360+02:00 ERROR 47760 --- [Backend NTR-Website] [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/api] threw exception
java.lang.IllegalArgumentException: Invalid bearer token

well that tells you what the issue is
but why is it invalid? it is just a token that has been given?
seems like
findByEmail
doesn't find any userpackage com.example.backend.repository;
import com.example.backend.models.CustomUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
This message has been formatted automatically. You can disable this using
/preferences
.What about ... using a debugger?
package com.example.backend.repository;
import com.example.backend.models.EventRegistration;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.UUID;
This message has been formatted automatically. You can disable this using
/preferences
.It looks like you are having issues with debugging or issues that can be solved using a debugger.
Check out this article on dev.java to see how debugging works and how to use a debugger.
This Stack Overflow question and its answers also explain debugging in general.
These links describe how to use the debugger in some IDEs:
⢠Debugging in IntelliJ
⢠Debugging in Eclipse
uhh it is hard to learn how to actually use those things since ppl advice is just use them but don t get further than click the bug and put a few red dots š
The links there decribe it pretty well IMO
Essentially the purpose of debugging is to see what's going on when running a program
but just do this and press the bug then?

you can create a breakpoint (the red dot) and when the program reaches that breakpoint, it suspends (stops)
on line 48 mb
put it before that
but idk how well it works with streams

guess my backend wants an email connected to each req but don t have that for this one
ahere you see variables and their values
and you can go through the program step by step
Does a user with that email exist?
looks like that
register and login work
but also want to sign ppl up for an event without having to log in
then I guess you need to change the backend to allow that
hope im capable of doing that :boohoo:

daniel now i get this im going crazy



nv think i did it lemme check
Cross-Origin-aanvraag geblokkeerd: de Same Origin Policy staat het lezen van de externe bron op http://localhost:8080/api/registrations niet toe. (Reden: CORS-aanvraag is niet gelukt). Statuscode: (null).
well if you are on one website, it cannot just read the content of another
package com.example.backend.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
This message has been formatted automatically. You can disable this using
/preferences
.have this for that
and your frontend is on localhost:8081?
http://localhost:8081/event
yep
š
Can you try without allowedMethods and allowedMethods maybe?
Also I assume your main class is in
com.example.backend
??

why tf does it still say i can taccess it

]


Does it still show the CORS error or just 401?
401
Debug the doFilterInternal and see what happens



should be excluded alsmost gotta go just want this stupid code to work have been on it for 5 hours
@dan1st | Daniel
you can use the "step over" button to see what the code does next


well see what happens and why you get the unauthorized
btw you can also use "step into" if you want to see what happens within a called method
e.g. in
validateAndSetAuthentication
i have no f clue and after 5 hours i just want it to work
don t feel like the debugger does much either

use the debugger to see what happens and why it gets to a point where it sends a 401
guess gonna give up then don t have enough enthiusm to look any longer at it
I don't think it should be difficult but if you don't try, you won't learn how to use a debugger properly
I tried for 5 hours lol at some point the focuss is gonna heading to a nightshift now š
:kekw:
š¤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.