Axios将GET和POST请求发送到localhost而不是heroku上的URL。 我正在heroku上运行spring boot应用程序,并在heroku上运行nuxt应用程序。我想将baseUrl从http://localhost:8080更改为https://spring-boota.herokuapp.com,但这是行不通的。
store / index.js
export const state = () => ({
// Server - Back End Base Url
baseUrl:'https://localhost:8080',
prwtokolaUrl: 'v1/prwtokola',
deigmataUrl: 'v1/deigmata',
picturesUrl: 'v1/pictures',
filesUrl: 'v1/files',
deigmaThhlastikwnUrl: 'v1/deigmaThhlastikwn',
thhlastikaCtEidosUrl: 'v1/ctThhlastikaEidh',
thhlastikaCtPressThreatsUrl: 'v1/ctThhlastikaPressThreats',
thhlastikaXEidhUrl: 'v1/deigmaThhlastikwnXEidh',
thhlastikaXPressThreatsUrl: 'v1/deigmaThhlastikwnXPressThreats',
})
export const getters = {
// Prwtokola
getPrwtokolaAddUrl: state => {
return state.baseUrl + state.prwtokolaUrl
},
getPrwtokolaAddFromExcelUrl: state => {
return state.baseUrl + state.prwtokolaUrl + '/addPrwtokolaFromExcel'
},
getPrwtokolaSearchUrl: state => {
return state.baseUrl + state.prwtokolaUrl + '/getAllByPaging'
},
getPrwtokolaByIdUrl: state => {
return state.baseUrl + state.prwtokolaUrl + '/'
},
getPrwtokolaDistinctUrl: state => {
return state.baseUrl + state.prwtokolaUrl + '/getDistinctIds'
},
// Deigmata
getDeigmataSearchUrl: state => {
return state.baseUrl + state.deigmataUrl + '/getAllByPaging'
},
getDeigmataByIdUrl: state => {
return state.baseUrl + state.deigmataUrl + '/'
},
getDeigmataDynamicSearchUrl: state => {
return state.baseUrl + state.deigmataUrl + '/search'
},
getDeigmataDynamicDownloadUrl: state => {
return state.baseUrl + state.deigmataUrl + '/downloadExcel'
},
getDeigmataAutocompletes: state => {
return state.baseUrl + state.deigmataUrl + '/getAutocompletes'
},
// Deigma Thhlastikwn
getDeigmaThhlastikwnAddUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl
},
getDeigmaThhlastikwnAddFromExcelUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/addDeigmaThhlastikwnFromExcel'
},
getDeigmaThhlastikwnSearchUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/getAllByPaging'
},
getDeigmaThhlastikwnByIdUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/'
},
getDeigmaThhlastikwnAutocompletesUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/getAutocompletes'
},
getDeigmaThhlastikwnMapMarkersUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/getAllGeoLocations'
},
getDeigmaThhlastikwnDynamicSearchUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/search'
},
getDeigmaThhlastikwnDynamicDownloadUrl: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/downloadExcel'
},
getDeigmaThhlastikwnAutocompletes: state => {
return state.baseUrl + state.deigmaThhlastikwnUrl + '/getAutocompletes'
},
// Pictures
getPictureByIdUrl: state => {
return state.baseUrl + state.picturesUrl + '/'
},
getPicturesByDeigmaThhlastikwnIdIs: state => {
return state.baseUrl + state.picturesUrl + '/getPicturesByDeigmaThhlastikwnIs/'
},
getPicturesSearchUrl: state => {
return state.baseUrl + state.picturesUrl + '/getAllByPaging/'
},
// Files
getFileByIdUrl: state => {
return state.baseUrl + state.filesUrl + '/'
},
getFilesByDeigmaThhlastikwnIdIs: state => {
return state.baseUrl + state.filesUrl + '/getFilesByDeigmaThhlastikwnIs/'
},
getFilesSearchUrl: state => {
return state.baseUrl + state.filesUrl + '/getAllByPaging/'
},
// Ct Eidh
getThhlastikaCtEidosAddUrl: state => {
return state.baseUrl + state.thhlastikaCtEidosUrl
},
getThhlastikaCtEidosAddFromExcelUrl: state => {
return state.baseUrl + state.thhlastikaCtEidosUrl + '/addEidhFromExcel'
},
getThhlastikaCtEidosSearchUrl: state => {
return state.baseUrl + state.thhlastikaCtEidosUrl + '/getAllByPaging'
},
getThhlastikaCtEidosByIdUrl: state => {
return state.baseUrl + state.thhlastikaCtEidosUrl + '/'
},
getThhlastikaCtEidosDistinctUrl: state => {
return state.baseUrl + state.thhlastikaCtEidosUrl + '/getAllEidh'
},
getCtEidhDynamicSearchUrl: state => {
return state.baseUrl + state.thhlastikaCtEidosUrl + '/search'
},
getCtEidhDynamicDownloadUrl: state => {
return state.baseUrl + state.thhlastikaCtEidosUrl + '/downloadExcel'
},
// Ct PressThreats
getThhlastikaCtPressThreatsAddUrl: state => {
return state.baseUrl + state.thhlastikaCtPressThreatsUrl
},
getThhlastikaCtPressThreatsAddFromExcelUrl: state => {
return state.baseUrl + state.thhlastikaCtPressThreatsUrl + '/addPressThreatsFromExcel'
},
getThhlastikaCtPressThreatsSearchUrl: state => {
return state.baseUrl + state.thhlastikaCtPressThreatsUrl + '/getAllByPaging'
},
getThhlastikaCtPressThreatsByIdUrl: state => {
return state.baseUrl + state.thhlastikaCtPressThreatsUrl + '/'
},
getThhlastikaCtPressThreatsDistinctUrl: state => {
return state.baseUrl + state.thhlastikaCtPressThreatsUrl + '/getAllActCodes'
},
getCtPressThreatsDynamicSearchUrl: state => {
return state.baseUrl + state.thhlastikaCtPressThreatsUrl + '/search'
},
getCtPressThreatsDynamicDownloadUrl: state => {
return state.baseUrl + state.thhlastikaCtPressThreatsUrl + '/downloadExcel'
},
// Thhlastika X Eidh
getThhlastikaXEidhAddUrl: state => {
return state.baseUrl + state.thhlastikaXEidhUrl
},
getThhlastikaXEidhAddFromExcelUrl: state => {
return state.baseUrl + state.thhlastikaXEidhUrl + '/addDeigmaThhlastikwnXEidhFromExcel'
},
getThhlastikaXEidhSearchUrl: state => {
return state.baseUrl + state.thhlastikaXEidhUrl + '/getAllByPaging'
},
getThhlastikaXEidhByIdUrl: state => {
return state.baseUrl + state.thhlastikaXEidhUrl + '/'
},
getThhlastikaXEidhByDeigmaThhlastikwnIdIs: state => {
return state.baseUrl + state.thhlastikaXEidhUrl + '/getDeigmaThhlastikwnXEidhByDeigmaThhlastikwnIs/'
},
getThhlastikaXEidhDynamicSearchUrl: state => {
return state.baseUrl + state.thhlastikaXEidhUrl + '/search'
},
getThhlastikaXEidhDynamicDownloadUrl: state => {
return state.baseUrl + state.thhlastikaXEidhUrl + '/downloadExcel'
},
getThhlastikaXEidhAutocompletes: state => {
return state.baseUrl + state.thhlastikaXEidhUrl + '/getAutocompletes'
},
// Thhlastika X PressThreats
getThhlastikaXPressThreatsAddUrl: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl
},
getThhlastikaXPressThreatsAddFromExcelUrl: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl + '/addDeigmaThhlastikwnXPressThreatsFromExcel'
},
getThhlastikaXPressThreatsSearchUrl: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl + '/getAllByPaging'
},
getThhlastikaXPressThreatsByIdUrl: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl + '/'
},
getThhlastikaXPressThreatsByDeigmaThhlastikwnIdIs: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl + '/getDeigmaThhlastikwnXPressThreatsByDeigmaThhlastikwnIs/'
},
getThhlastikaXPressThreatsDynamicSearchUrl: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl + '/search'
},
getThhlastikaXPressThreatsDynamicDownloadUrl: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl + '/downloadExcel'
},
getThhlastikaXPressThreatsAutocompletes: state => {
return state.baseUrl + state.thhlastikaXPressThreatsUrl + '/getAutocompletes'
},
}
export const mutations = {
// setSnackbar (state, snackbar) {
// state.snackbar = snackbar
// },
}
export const actions = {
// setSnackbarSettings ({ commit }, snackbar, snackbarColor, snackbarText) {
// commit('setSnackbarColor', snackbarColor)
// },
}
我的nuxt.config.js
const pkg = require('./package')
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
htmlAttrs: {
lang: 'el'
},
title: 'Φορέας Διαχείρισης Λίμνης Κερκίνης',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Ο Φορέας Διαχείρισης Λίμνης Κερκίνης είναι υπεύθυνος για την μελέτη, συλλογή, αποθήκευση και ανάλυση πληροφοριών με τη δημιουργία στατιστικών για τη περιοχή της Λίμνης Κερκίνης.' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/logo.png' },
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#1B5E20' },
/*
** Global CSS
*/
css: [
'~/assets/style/app.styl'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'@/plugins/vuetify'
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://github.com/nuxt-community/axios-module#usage
'@nuxtjs/axios'
],
/*
** Axios module configuration
*/
axios: {
},
env: {
apiBaseUrl:'https://spring-boota.herokuapp.com'
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
},
}
Heroku上的Spring Boot View日志
2019-04-25T09:43:00.992627+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[kerkinibackend-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2019-04-25T09:43:00.992628+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[kerkinibackend-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2019-04-25T09:43:00.992631+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[kerkinibackend-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2019-04-25T09:43:00.992632+00:00 app[web.1]: Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
2019-04-25T09:43:00.992633+00:00 app[web.1]: at org.postgresql.Driver.notImplemented(Driver.java:683) ~[postgresql-42.2.2.jar!/:42.2.2]
2019-04-25T09:43:00.992634+00:00 app[web.1]: at org.postgresql.jdbc.PgConnection.createClob(PgConnection.java:1252) ~[postgresql-42.2.2.jar!/:42.2.2]
2019-04-25T09:43:00.992636+00:00 app[web.1]: ... 52 common frames omitted
2019-04-25T09:43:00.992637+00:00 app[web.1]:
2019-04-25T09:43:01.000940+00:00 app[web.1]: 2019-04-25 09:43:01.000 INFO 4 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@74bf1791
2019-04-25T09:43:03.156892+00:00 app[web.1]: 2019-04-25 09:43:03.156 INFO 4 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-04-25T09:43:04.903510+00:00 app[web.1]: 2019-04-25 09:43:04.903 INFO 4 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-25T09:43:04.983028+00:00 app[web.1]: 2019-04-25 09:43:04.982 WARN 4 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2019-04-25T09:43:05.424035+00:00 app[web.1]: 2019-04-25 09:43:05.423 INFO 4 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 21819 (http) with context path ''
2019-04-25T09:43:05.427954+00:00 app[web.1]: 2019-04-25 09:43:05.427 INFO 4 --- [ main] c.t.k.KerkinibackendApplication : Started KerkinibackendApplication in 11.091 seconds (JVM running for 12.095)
2019-04-25T09:43:05.824560+00:00 heroku[web.1]: State changed from starting to up
答案 0 :(得分:0)
如何在nuxt.config中为axios设置baseURL?
axios: {
baseURL: 'https://spring-boota.herokuapp.com'
}