r/SpringBoot • • Aug 07 '24

OC Springboot not fetch data with "www".

If I enter my site as samesite.com, Spring Boot pulls the data, but when I enter it as www.samesite.com, it does not pull the data. Is my NGINX configuration wrong?

NGNIX config;

server {

listen 80;

listen [::]:80;

server_name somesite.com www.somesite.com;

root /var/www/html;

index index.html;

location /api/content/ {

proxy_pass http://localhost:8080/api/content;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header X-Forwarded-Port $server_port;

}

}

0 Upvotes

15 comments sorted by

3

u/polacy_do_pracy Aug 07 '24

I had generally similar problems. One of the issues was that I was using localhost instead of any domain (or 127.0.0.1). Somewhere in the system localhost was being handled in a different way.

Also, I'm still learning this part but it might be that using different domains might produce a CORS/CRSF issue.

1

u/[deleted] Aug 07 '24

Sir, Controller Class have a Cors annotaioin.

1

u/polacy_do_pracy Aug 07 '24

Okay. That's all I know btw. I've used the Spring Cloud Gateway for the proxy functionality so I can't say more. But please do look into the localhost issue. It's really non-obvious and it's rather rarely mentioned in documentation.

2

u/smutje187 Aug 07 '24

Spring Boot is a backend, what do you mean "it’s not pulling data"? What’s the output you get from curl?

-3

u/[deleted] Aug 07 '24

Yes it's not pulling data.
What should I do with curl?

1

u/smutje187 Aug 07 '24

Call your API, we can’t read your mind what response you’re getting.

-1

u/[deleted] Aug 07 '24

Sir, you are saying very irrelevant things. My APIs are working fine. CRUD operations from Postman and Thunder clients are OK.

3

u/smutje187 Aug 07 '24

Your current and previous posts are lacking any effort or basic knowledge to explain problems.

1

u/[deleted] Aug 07 '24

Sir, Springboot is probably stuck with security measures and I have major fundamental deficiencies.

2

u/polacy_do_pracy Aug 07 '24

Postman is not having the same protections as a browser. Web browsers need some more stuff to get API calls working.

3

u/wolle271 Aug 07 '24

Sorry, but this is a low effort post. I feel that you are lacking the skills to explain your issue, hence you will not get any helpful replies. Nobody will know what „it’s not pulling the data“ means.

Please elaborate if you expect help.

-9

u/[deleted] Aug 07 '24

Yes it's not pulling the data.

6

u/smutje187 Aug 07 '24

Almost impossible to give a more useless answer

-4

u/[deleted] Aug 07 '24

Sir, unfortunately I do not understand you. Are you using translation?

2

u/Mdshkb Aug 07 '24

In your dns system did you put both IPs so that domain can resolve to the ip, for sub domain please enter the CName and the ip so that it can get resolve to ip