I have a webpack-dev-server running with node.js on :8080
serving my frontend. I have a Spring Boot MVC application running on :8088
serving my actual backend service.
I have a login system I want to call on :8088, how would I change the permanent settings of the fetch
function to refer to :8088
instead of :8080
every time the function is called?
I've tried the following, but to no avail:
login ({commit}, authData) {
fetch('/api/login', {
username: authData.username,
password: authData.password
}, {
mode: 'no-cors',
method: 'post',
url: `http://localhost:8088`,
credentials: 'include'
}) // ... goes on
However, it still refers to 8080:
bodyUsed: false
headers: Headers { }
ok: true
redirected: false
status: 200
statusText: "OK"
type: "basic"
url: "http://localhost:8080/api/login"
Have you tried to put full url in your fetch first parameter? Pretty sure /api/login
would make the request to the current host.
fetch('http://localhost:8088/api/login', {
username: authData.username,
password: authData.password
}, {
mode: 'no-cors',
method: 'post',
url: `http://localhost:8088`,
credentials: 'include'
})
Of course you need to have CORS enabled for this to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With